* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <GL/freeglut.h>
#include "freeglut_internal.h"
);
if( !fgDisplay.DisplayModeValid )
- fgWarning( "Runtime use of XF86VidModeGetModeLine failed.\n" );
+ fgWarning( "Runtime use of XF86VidModeGetModeLine failed." );
# else
/*
*/
XFlush( fgDisplay.Display );
- return;
+ break;
}
}
+ XFree( displayModes );
}
# else
*/
static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
{
+ GLboolean success = GL_FALSE;
#if TARGET_HOST_UNIX_X11
/*
if( haveToTest || fgDisplay.DisplayModeValid )
{
XF86VidModeModeInfo** displayModes;
- int i, displayModesCount;
+ int i, ignoreRefreshRate, displayModesCount;
XF86VidModeGetAllModeLines(
fgDisplay.Display,
&displayModes
);
- /* Check every of the modes looking for one that matches our demands */
- for( i = 0; i < displayModesCount; i++ )
+ /*
+ * 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++)
{
- if( fghCheckDisplayMode( displayModes[ i ]->hdisplay,
- displayModes[ i ]->vdisplay,
- fgState.GameModeDepth,
- fgState.GameModeRefresh ) )
+ for( i = 0;
+ !success && ( i < displayModesCount );
+ i++ )
{
- if( haveToTest )
- return GL_TRUE;
- /* OKi, this is the display mode we have been looking for... */
- XF86VidModeSwitchToMode(
- fgDisplay.Display,
- fgDisplay.Screen,
- displayModes[ i ]
- );
- return GL_TRUE;
+ /* 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 ) );
}
}
- }
- /* Something must have gone wrong */
- return GL_FALSE;
+ if( !haveToTest && success ) {
+ XF86VidModeSwitchToMode( fgDisplay.Display, fgDisplay.Screen, displayModes[ i ] );
+ }
+
+ XFree( displayModes );
+ }
# else
/*
#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
unsigned int displayModes = 0, mode = 0xffffffff;
- GLboolean success = GL_FALSE;
/* HDC desktopDC; */
DEVMODE devMode;
}
}
- return success;
-
#endif
+
+ return success;
}
{
int width = 640, height = 480, depth = 16, refresh = 72;
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );
+
/*
* This one seems a bit easier than glutInitDisplayString. The bad thing
* about it that I was unable to find the game mode string definition, so
*/
int FGAPIENTRY glutEnterGameMode( void )
{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" );
+
if( fgStructure.GameMode )
fgAddToWindowDestroyList( fgStructure.GameMode );
else
*/
void FGAPIENTRY glutLeaveGameMode( void )
{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveGameMode" );
+
freeglut_return_if_fail( fgStructure.GameMode );
fgStructure.GameMode->State.IsGameMode = GL_FALSE;
fgAddToWindowDestroyList( fgStructure.GameMode );
-
fgStructure.GameMode = NULL;
#if TARGET_HOST_UNIX_X11
*/
int FGAPIENTRY glutGameModeGet( GLenum eWhat )
{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeGet" );
+
switch( eWhat )
{
case GLUT_GAME_MODE_ACTIVE:
return !!fgStructure.GameMode;
}
+ fgWarning( "Unknown gamemode get: %d", eWhat );
return -1;
}