Tao.Sdl SDK Documentation

Sdl.SDL_SetVideoMode Method 

Set up a video mode with the specified width, height and bits-per-pixel.

[Visual Basic]
Public Shared Function SDL_SetVideoMode( _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal bpp As Integer, _
   ByVal flags As Integer _
) As IntPtr
[C#]
public static IntPtr SDL_SetVideoMode(
   int width,
   int height,
   int bpp,
   int flags
);

Parameters

width
height
bpp
flags

Return Value

The framebuffer surface, or NULL if it fails. The surface returned is freed by SDL_Quit() and should not be freed by the caller.

Remarks

If 'bpp' is 0, it is treated as the current display bits per pixel.

The flags parameter is the same as the flags field of the SDL_Surface structure. OR'd combinations of the following values are valid.

FlagDescription
SDL_SWSURFACECreate the video surface in system memory.
SDL_HWSURFACECreate the video surface in video memory ,if possible, and you may have to call SDL_LockSurface() in order to access the raw framebuffer. Otherwise, the video surface will be created in system memory.
SDL_ASYNCBLITEnables the use of asynchronous updates of the display surface, but you must always lock before accessing pixels. SDL will wait for updates to complete before returning from the lock. This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems.
SDL_ANYFORMATNormally, if a video surface of the requested bits-per-pixel (bpp) is not available, SDL will emulate one with a shadow surface. Passing SDL_ANYFORMAT prevents this and causes SDL to use the video surface, regardless of its pixel depth.
SDL_HWPALETTEGive SDL exclusive palette access. Without this flag you may not always get the the colors you request with SDL_SetColors or SDL_SetPalette. You should look at the video surface structure to determine the actual palette. If SDL cannot guarantee that the colors you request can be set, i.e. if the colormap is shared, then the video surface may be created under emulation in system memory, overriding the SDL_HWSURFACE flag.
SDL_DOUBLEBUFEnable hardware double buffering; only valid with SDL_HWSURFACE. Calling SDL_Flip will flip the buffers and update the screen. All drawing will take place on the surface that is not displayed at the moment. If double buffering could not be enabled then SDL_Flip will just perform a SDL_UpdateRect on the entire screen. This is usually slower than the normal single-buffering scheme, but prevents "tearing" artifacts caused by modifying video memory while the monitor is refreshing. It should only be used by applications that redraw the entire screen on every update.
SDL_FULLSCREENSDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason), the next higher resolution will be used and the display window centered on a black background. The default is to create a windowed mode if the current graphics system has a window manager. If the SDL library is able to set a fullscreen video mode, this flag will be set in the surface that is returned.
SDL_OPENGLCreate an OpenGL rendering context. You should have previously set OpenGL video attributes with SDL_GL_SetAttribute.
SDL_OPENGLBLITCreate an OpenGL rendering context, like above, but allow normal blitting operations. The screen (2D) surface may have an alpha channel, and SDL_UpdateRects must be used for updating changes to the screen surface. NOTE: This option is kept for compatibility only, and is not recommended for new code.
SDL_RESIZABLECreate a resizable window. When the window is resized by the user a SDL_VIDEORESIZE event is generated and SDL_SetVideoMode can be called again with the new size.
SDL_NOFRAMEIf possible, SDL_NOFRAME causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.
If you rely on functionality provided by certain video flags, check the flags of the returned surface to make sure that functionality is available. SDL will fall back to reduced functionality if the exact flags you wanted are not available.

Whatever flags SDL_SetVideoMode could satisfy are set in the flags member of the returned surface.

The bpp parameter is the number of bits per pixel, so a bpp of 24 uses the packed representation of 3 bytes/pixel. For the more common 4 bytes/pixel mode, use a bpp of 32. Somewhat oddly, both 15 and 16 will request a 2 bytes/pixel mode, but different pixel formats.

Binds to C-function call in SDL_video.h:

extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode
            (int width, int height, int bpp, Uint32 flags);

See Also

Sdl Class | Tao.Sdl Namespace | SDL_LockSurface | SDL_SetColors | SDL_Flip | SDL_Surface