X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_gamemode.c;fp=src%2Ffreeglut_gamemode.c;h=7569d1f2c4eaf5b8ec780a410be532135ed186fc;hb=364e1ba69200b10cb2b7108cbaeafe98ac630281;hp=137f1ea54e6bb5a6e5553ff76d7bdda657689043;hpb=60eebdfbfc89ee4df98ac8a5678b93b397ccc172;p=freeglut diff --git a/src/freeglut_gamemode.c b/src/freeglut_gamemode.c index 137f1ea..7569d1f 100644 --- a/src/freeglut_gamemode.c +++ b/src/freeglut_gamemode.c @@ -364,7 +364,7 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest ) # ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H /* - * This is also used by applcations which check modes by calling + * This is also used by applications which check modes by calling * glutGameModeGet(GLUT_GAME_MODE_POSSIBLE), so allow the check: */ if( haveToTest || fgDisplay.DisplayModeValid ) @@ -372,6 +372,33 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest ) XF86VidModeModeInfo** displayModes; int i, displayModesCount; + /* current display mode was queried in fghRememberState + * set defaulted values to the current display mode's + */ + if (fgState.GameModeSize.X == -1) + { + fgState.GameModeSize.X = fgDisplay.DisplayMode.hdisplay; + } + if (fgState.GameModeSize.Y == -1) + { + fgState.GameModeSize.Y = fgDisplay.DisplayMode.vdisplay; + } + if (fgState.GameModeDepth == -1) + { + /* can't get color depth from this, nor can we change it, do nothing + * TODO: get with XGetVisualInfo()? but then how to set? + */ + } + if (fgState.GameModeRefresh != -1) + { + /* Compute the displays refresh rate, dotclock comes in kHz. */ + int refresh = ( fgDisplay.DisplayModeClock * 1000 ) / + ( fgDisplay.DisplayMode.htotal * fgDisplay.DisplayMode.vtotal ); + + fgState.GameModeRefresh = refresh; + } + + /* query all possible display modes */ if( !XF86VidModeGetAllModeLines( fgDisplay.Display, fgDisplay.Screen, @@ -516,11 +543,14 @@ void FGAPIENTRY glutGameModeString( const char* string ) string ); - /* Hopefully it worked, and if not, we still have the default values */ - if ( width > 0 ) fgState.GameModeSize.X = width; - if ( height > 0 ) fgState.GameModeSize.Y = height; - if ( depth > 0 ) fgState.GameModeDepth = depth; - if ( refresh > 0 ) fgState.GameModeRefresh = refresh; + /* All values not specified are now set to -1, which means those + * aspects of the current display mode are not changed in + * fghChangeDisplayMode() above. + */ + fgState.GameModeSize.X = width; + fgState.GameModeSize.Y = height; + fgState.GameModeDepth = depth; + fgState.GameModeRefresh = refresh; }