Table of Contents

 
StartUp
 

Purpose

Sets up SDL video and the primary surface

 

Protoype

void CVideo::StartUp (int i_width, int i_height, int i_bpp, Uint32 i_flags, string str_title = "SDL_app", 
                      string str_icon = "", bool b_cursor = true)
 

Parameters

width the width of the screen (primary surface)
height the height of the screen (primary surface)
bpp the bit depth of the screen (primary surface)
flags the primary surface creation flags
title the title for windowed applications
icon the name or path of the icon for windowed applications
cursor whether to show (TRUE) the system cursor of hide it (FALSE)
 

Description

This function sets up the SDL video and primary surface. You define the surface dimensions along with the flags that will tell SDL what kind of surface it's dealing with. You can OR any of these following flags together

SDL_SWSURFACE Create the video surface in system memory
SDL_HWSURFACE Create the video surface in video memory
SDL_ASYNCBLIT Enables the use of asynchronous updates of the display surface. This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems.
SDL_ANYFORMAT Normally, 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_DOUBLEBUF Enable hardware double buffering; only valid with SDL_HWSURFACE.
SDL_FULLSCREEN SDL 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.
SDL_RESIZABLE Create a resizable window.
SDL_NOFRAME If possible, SDL_NOFRAME causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.

In addition to the above flags CVideo has three presets: WINDOWED, FULLSCREEN, and SPLASH. The first two are self-explanitory, the third may be a little confusing - it creates a frameless non-fullscreen surface that can be used to display a splash image.

After defining the surface dimensions you have the option of setting the caption of the application as well as the icon associated with it. If it is a fullscreen application then neither of these two parameters will apply. The application name will appear in both the application title bar and it's button in the taskbar. The icon must be a 32x32 bitmap file.

Lastly, you can enable or disable the system mouse cursor with a flag. To show the cursor, use TRUE, otherwise use FALSE to hide it. If it is a fullscreen application the system cursor will not show regardless.

 

Use

CVideo video;
// create a windowed app
video.StartUp(800, 600, 32, WINDOWED, "My App", "app.bmp");
// create a fullscreen app
video.StartUp(1024, 768, 32, FULLSCREEEN);
 

Prev: ShutDownFPS