#endif
}
+#if TARGET_HOST_UNIX_X11
+#ifdef X_XF86VidModeGetAllModeLines
+
/*
- * Checks the display mode settings against user's preferences
+ * Checks a single display mode settings against user's preferences.
*/
static GLboolean fghCheckDisplayMode( int width, int height, int depth, int refresh )
{
return ( width == fgState.GameModeSize.X ) &&
( height == fgState.GameModeSize.Y ) &&
( depth == fgState.GameModeDepth ) &&
- (refresh == fgState.GameModeRefresh );
+ ( refresh == fgState.GameModeRefresh );
+}
+
+/*
+ * Checks all display modes settings against user's preferences.
+ * Returns the mode number found or -1 if none could be found.
+ */
+static int fghCheckDisplayModes( GLboolean exactMatch, int displayModesCount, XF86VidModeModeInfo** displayModes )
+{
+ int i;
+ for( i = 0; i < displayModesCount; i++ )
+ {
+ /* Compute the displays refresh rate, dotclock comes in kHz. */
+ int refresh = ( displayModes[ i ]->dotclock * 1000 ) /
+ ( displayModes[ i ]->htotal * displayModes[ i ]->vtotal );
+
+ if( fghCheckDisplayMode( displayModes[ i ]->hdisplay,
+ displayModes[ i ]->vdisplay,
+ fgState.GameModeDepth,
+ ( exactMatch ? refresh : fgState.GameModeRefresh ) ) ) {
+ return i;
+ }
+ }
+ return -1;
}
+#endif
+#endif
+
/*
* Changes the current display mode to match user's settings
*/
if( haveToTest || fgDisplay.DisplayModeValid )
{
XF86VidModeModeInfo** displayModes;
- int i, ignoreRefreshRate, displayModesCount;
+ int i, displayModesCount;
if( !XF86VidModeGetAllModeLines(
fgDisplay.Display,
* Check every of the modes looking for one that matches our demands,
* ignoring the refresh rate if no exact match could be found.
*/
- for( ignoreRefreshRate = 0;
- !success && ( ignoreRefreshRate <= 1 );
- ignoreRefreshRate++)
- {
- for( i = 0;
- !success && ( i < displayModesCount );
- i++ )
- {
- /* Compute the displays refresh rate, dotclock comes in kHz. */
- int refresh = ( displayModes[ i ]->dotclock * 1000 ) /
- ( displayModes[ i ]->htotal * displayModes[ i ]->vtotal );
-
- success = fghCheckDisplayMode( displayModes[ i ]->hdisplay,
- displayModes[ i ]->vdisplay,
- fgState.GameModeDepth,
- ( ignoreRefreshRate ? fgState.GameModeRefresh : refresh ) );
- }
+ i = fghCheckDisplayModes( GL_TRUE, displayModesCount, displayModes );
+ if( i < 0 ) {
+ i = fghCheckDisplayModes( GL_FALSE, displayModesCount, displayModes );
}
+ success = ( i < 0 ) ? GL_FALSE : GL_TRUE;
if( !haveToTest && success ) {
if( !XF86VidModeSwitchToMode(
#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
DEVMODE devMode;
- char fggmstr[255]="";
+ char *fggmstr = NULL;
success = GL_FALSE;
case DISP_CHANGE_SUCCESSFUL:
success = GL_TRUE;
- // update vars in case if windows switched to proper mode
+ /* update vars in case if windows switched to proper mode */
EnumDisplaySettings( NULL, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
fgState.GameModeSize.X = devMode.dmPelsWidth;
fgState.GameModeSize.Y = devMode.dmPelsHeight;
fgState.GameModeRefresh = devMode.dmDisplayFrequency;
break;
case DISP_CHANGE_RESTART:
- strcpy(fggmstr,"The computer must be restarted for the graphics mode to work.");
+ fggmstr = "The computer must be restarted for the graphics mode to work.";
break;
case DISP_CHANGE_BADFLAGS:
- strcpy(fggmstr,"An invalid set of flags was passed in.");
+ fggmstr = "An invalid set of flags was passed in.";
break;
case DISP_CHANGE_BADPARAM:
- strcpy(fggmstr,"An invalid parameter was passed in. This can include an invalid flag or combination of flags.");
+ fggmstr = "An invalid parameter was passed in. This can include an invalid flag or combination of flags.";
break;
case DISP_CHANGE_FAILED:
- strcpy(fggmstr,"The display driver failed the specified graphics mode.");
+ fggmstr = "The display driver failed the specified graphics mode.";
break;
case DISP_CHANGE_BADMODE:
- strcpy(fggmstr,"The graphics mode is not supported.");
+ fggmstr = "The graphics mode is not supported.";
break;
default:
- strcpy(fggmstr,"Unknown error in graphics mode???"); /* dunno if it is possible,MSDN does not mention any other error */
+ fggmstr = "Unknown error in graphics mode???"; /* dunno if it is possible,MSDN does not mention any other error */
break;
}
if( ! fghChangeDisplayMode( GL_FALSE ) )
{
fgWarning( "failed to change screen settings" );
- return FALSE;
+ return 0;
}
fgStructure.GameMode = fgCreateWindow(
fgStructure.GameMode->State.Width = fgState.GameModeSize.X;
fgStructure.GameMode->State.Height = fgState.GameModeSize.Y;
+ fgStructure.GameMode->State.NeedToResize = GL_TRUE;
fgStructure.GameMode->State.IsGameMode = GL_TRUE;
#endif
- return TRUE;
+ return fgStructure.GameMode->ID;
}
/*