X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_gamemode.c;h=d6c6a25642cd13c0c66d4b07c68ff8e0be7ab9af;hb=a351855ee6b2ec6f477635a367c745d733219c3e;hp=591df3869384a580905b3e582d6d2e818980e666;hpb=a86a957ae87e1b07260edec971ebdf5a98ff3d54;p=freeglut diff --git a/freeglut-1.3/freeglut_gamemode.c b/freeglut-1.3/freeglut_gamemode.c index 591df38..d6c6a25 100644 --- a/freeglut-1.3/freeglut_gamemode.c +++ b/freeglut-1.3/freeglut_gamemode.c @@ -32,7 +32,7 @@ #define G_LOG_DOMAIN "freeglut-gamemode" #include "../include/GL/freeglut.h" -#include "../include/GL/freeglut_internal.h" +#include "freeglut_internal.h" /* * TODO BEFORE THE STABLE RELEASE: @@ -75,12 +75,16 @@ void fghRememberState( void ) #elif TARGET_HOST_WIN32 - DEVMODE devMode; +/* DEVMODE devMode; */ /* * Grab the current desktop settings... */ - EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &fgDisplay.DisplayMode ); + +/* hack to get around my stupid cross-gcc headers */ +#define FREEGLUT_ENUM_CURRENT_SETTINGS -1 + + EnumDisplaySettings( NULL, FREEGLUT_ENUM_CURRENT_SETTINGS, &fgDisplay.DisplayMode ); /* * Make sure we will be restoring all settings needed @@ -133,6 +137,15 @@ void fghRestoreState( void ) displayModes[ i ] ); + /* + * In case this will be the last X11 call we do before exit, + * we've to flush the X11 output queue to be sure the command + * is really brought onto it's way to the X server. + * The application should not do this because it + * would not be platform independent then. + */ + XFlush(fgDisplay.Display); + return; } } @@ -196,6 +209,8 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) if( fghCheckDisplayMode( displayModes[ i ]->hdisplay, displayModes[ i ]->vdisplay, fgState.GameModeDepth, fgState.GameModeRefresh ) ) { + if( haveToTest ) + return( TRUE ); /* * OKi, this is the display mode we have been looking for... */ @@ -233,13 +248,14 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) #elif TARGET_HOST_WIN32 - guint displayModes = 0, mode = 0xffffffff; - gboolean success = FALSE; - HDC desktopDC; + unsigned int displayModes = 0, mode = 0xffffffff; + GLboolean success = FALSE; +/* HDC desktopDC; */ DEVMODE devMode; /* * Enumerate the available display modes + * Try to get a complete match */ while( EnumDisplaySettings( NULL, displayModes, &devMode ) == TRUE ) { @@ -247,10 +263,10 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) * Does the enumerated display mode match the user's preferences? */ if( fghCheckDisplayMode( devMode.dmPelsWidth, devMode.dmPelsHeight, - devMode.dmBitsPerPel, fgState.GameModeRefresh ) ) + devMode.dmBitsPerPel, devMode.dmDisplayFrequency ) ) { /* - * OKi, we've found a matching display mode, remember it's number and break + * OKi, we've found a matching display mode, remember its number and break */ mode = displayModes; break; @@ -262,6 +278,35 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest ) displayModes++; } + if ( mode == 0xffffffff ) + { + /* then try without Display Frequency */ + displayModes = 0; + + /* + * Enumerate the available display modes + */ + while( EnumDisplaySettings( NULL, displayModes, &devMode ) == TRUE ) + { + /* then try without Display Frequency */ + + if( fghCheckDisplayMode( devMode.dmPelsWidth, devMode.dmPelsHeight, + devMode.dmBitsPerPel, fgState.GameModeRefresh)) + { + /* + * OKi, we've found a matching display mode, remember its number and break + */ + mode = displayModes; + break; + } + + /* + * Switch to the next display mode, if any + */ + displayModes++; + } + } + /* * Did we find a matching display mode? */ @@ -351,7 +396,7 @@ int FGAPIENTRY glutEnterGameMode( void ) /* * ...if so, delete it before proceeding... */ - fgDestroyWindow( fgStructure.GameMode, TRUE ); + fgAddToWindowDestroyList( fgStructure.GameMode, TRUE ); } else { @@ -366,7 +411,7 @@ int FGAPIENTRY glutEnterGameMode( void ) */ if( fghChangeDisplayMode( FALSE ) == FALSE ) { - fgWarning( "failed to change screen settings" ); + fgWarning( "failed to change screen settings" ); return( FALSE ); } @@ -430,9 +475,9 @@ void FGAPIENTRY glutLeaveGameMode( void ) freeglut_return_if_fail( fgStructure.GameMode != NULL ); /* - * First of all, have the game mode window created + * First of all, have the game mode window destroyed */ - fgDestroyWindow( fgStructure.GameMode, TRUE ); + fgAddToWindowDestroyList( fgStructure.GameMode, TRUE ); #if TARGET_HOST_UNIX_X11