I ini SDL like so:
Code:
struct sdldata
{
SDL_Event event;
int error;
const SDL_VideoInfo *videoInfo;
SDL_Surface* drawContext;
Uint32 flags;
};
void iniSDL(sdldata* sdldataToini)
{
/* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
Quit( 1 );
}
/* Fetch the video info */
sdldataToini->videoInfo = SDL_GetVideoInfo();
if ( !sdldataToini->videoInfo )
{
fprintf( stderr, "Video query failed: %s\n",
SDL_GetError( ) );
Quit( 1 );
}
/* the flags to pass to SDL_SetVideoMode */
sdldataToini->flags = SDL_OPENGL; /* Enable OpenGL in SDL */
sdldataToini->flags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
sdldataToini->flags |= SDL_HWPALETTE; /* Store the palette in hardware */
/* This checks to see if surfaces can be stored in memory */
if ( sdldataToini->videoInfo->hw_available )
sdldataToini->flags |= SDL_HWSURFACE;
else
sdldataToini->flags |= SDL_SWSURFACE;
/* This checks if hardware blits can be done */
if ( sdldataToini->videoInfo->blit_hw )
sdldataToini->flags |= SDL_HWACCEL;
/* Sets up OpenGL double buffering */
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
/* get a SDL surface */
sdldataToini->drawContext = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, sdldataToini->flags );
/* Verify there is a surface */
if ( !sdldataToini->drawContext )
{
fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) );
Quit( 1 );
}
}
Now when f1 is pressed it is supposed to toggle full screen:
Code:
void handleKeyPress (sdldata *mySDL)
{
switch ( mySDL->event.key.keysym.sym )
{
case SDLK_ESCAPE:
Quit(0);
break;
case SDLK_F1:
SDL_WM_ToggleFullScreen( mySDL->drawContext );
break;
default:
break;
}
}
I have tested and am sure that the function is getting called, but the program does not go full screen. I've used nearly this exact code in previous projects and it worked. I can't for the life of me see why it wouldn't work.
Any ideas?
Thanks