Fixing a bug which set the "ErrorFunc" field in the call to "glutInitWarningFunc"
[freeglut] / src / freeglut_gamemode.c
index 24a8be1..01086b3 100644 (file)
@@ -204,7 +204,7 @@ static void fghRestoreState( void )
 
 #elif TARGET_HOST_MS_WINDOWS
 
-    /* Restore the previously rememebered desktop display settings */
+    /* Restore the previously remembered desktop display settings */
     ChangeDisplaySettingsEx( fgDisplay.DisplayName,&fgDisplay.DisplayMode, 0,0,0 );
 
 #endif
@@ -242,6 +242,15 @@ static int fghCheckDisplayModes( GLboolean exactMatch, int displayModesCount, XF
                                  displayModes[ i ]->vdisplay,
                                  fgState.GameModeDepth,
                                  ( exactMatch ? refresh : fgState.GameModeRefresh ) ) ) {
+            if (!exactMatch)
+            {
+                /* Update the chosen refresh rate, otherwise a
+                 * glutGameModeGet(GLUT_GAME_MODE_REFRESH_RATE) would not
+                 * return the right values
+                 */
+                fgState.GameModeRefresh = refresh;
+            }
+
             return i;
         }
     }
@@ -419,10 +428,10 @@ void FGAPIENTRY glutGameModeString( const char* string )
                                 );
 
     /* Hopefully it worked, and if not, we still have the default values */
-    fgState.GameModeSize.X  = width;
-    fgState.GameModeSize.Y  = height;
-    fgState.GameModeDepth   = depth;
-    fgState.GameModeRefresh = refresh;
+    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;
 }