xf86VidMode error checking (Andrew Lentvorski)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@112 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
8cce55439e
commit
69cbc334a9
@ -62,13 +62,17 @@ void fghRememberState( void )
|
|||||||
/*
|
/*
|
||||||
* Query the current display settings:
|
* Query the current display settings:
|
||||||
*/
|
*/
|
||||||
XF86VidModeGetModeLine(
|
fgDisplay.DisplayModeValid =
|
||||||
|
XF86VidModeGetModeLine(
|
||||||
fgDisplay.Display,
|
fgDisplay.Display,
|
||||||
fgDisplay.Screen,
|
fgDisplay.Screen,
|
||||||
&fgDisplay.DisplayModeClock,
|
&fgDisplay.DisplayModeClock,
|
||||||
&fgDisplay.DisplayMode
|
&fgDisplay.DisplayMode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!fgDisplay.DisplayModeValid)
|
||||||
|
fgWarning( "Runtime use of XF86VidModeGetModeLine failed.\n" );
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# warning fghRememberState: missing XFree86 video mode extensions, game mode will not change screen resolution when activated
|
# warning fghRememberState: missing XFree86 video mode extensions, game mode will not change screen resolution when activated
|
||||||
# endif
|
# endif
|
||||||
@ -106,47 +110,50 @@ void fghRestoreState( void )
|
|||||||
*/
|
*/
|
||||||
# ifdef X_XF86VidModeGetAllModeLines
|
# ifdef X_XF86VidModeGetAllModeLines
|
||||||
|
|
||||||
XF86VidModeModeInfo** displayModes;
|
if (fgDisplay.DisplayModeValid)
|
||||||
int i, displayModesCount;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Query for all the display available...
|
|
||||||
*/
|
|
||||||
XF86VidModeGetAllModeLines(
|
|
||||||
fgDisplay.Display,
|
|
||||||
fgDisplay.Screen,
|
|
||||||
&displayModesCount,
|
|
||||||
&displayModes
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check every of the modes looking for one that matches our demands
|
|
||||||
*/
|
|
||||||
for( i=0; i<displayModesCount; i++ )
|
|
||||||
{
|
{
|
||||||
if( displayModes[ i ]->hdisplay == fgDisplay.DisplayMode.hdisplay &&
|
XF86VidModeModeInfo** displayModes;
|
||||||
displayModes[ i ]->vdisplay == fgDisplay.DisplayMode.vdisplay &&
|
int i, displayModesCount;
|
||||||
displayModes[ i ]->dotclock == fgDisplay.DisplayModeClock )
|
|
||||||
|
/*
|
||||||
|
* Query for all the display available...
|
||||||
|
*/
|
||||||
|
XF86VidModeGetAllModeLines(
|
||||||
|
fgDisplay.Display,
|
||||||
|
fgDisplay.Screen,
|
||||||
|
&displayModesCount,
|
||||||
|
&displayModes
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check every of the modes looking for one that matches our demands
|
||||||
|
*/
|
||||||
|
for( i=0; i<displayModesCount; i++ )
|
||||||
{
|
{
|
||||||
/*
|
if( displayModes[ i ]->hdisplay == fgDisplay.DisplayMode.hdisplay &&
|
||||||
* OKi, this is the display mode we have been looking for...
|
displayModes[ i ]->vdisplay == fgDisplay.DisplayMode.vdisplay &&
|
||||||
*/
|
displayModes[ i ]->dotclock == fgDisplay.DisplayModeClock )
|
||||||
XF86VidModeSwitchToMode(
|
{
|
||||||
fgDisplay.Display,
|
/*
|
||||||
fgDisplay.Screen,
|
* OKi, this is the display mode we have been looking for...
|
||||||
displayModes[ i ]
|
*/
|
||||||
);
|
XF86VidModeSwitchToMode(
|
||||||
|
fgDisplay.Display,
|
||||||
|
fgDisplay.Screen,
|
||||||
|
displayModes[ i ]
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In case this will be the last X11 call we do before exit,
|
* 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
|
* we've to flush the X11 output queue to be sure the command
|
||||||
* is really brought onto it's way to the X server.
|
* is really brought onto it's way to the X server.
|
||||||
* The application should not do this because it
|
* The application should not do this because it
|
||||||
* would not be platform independent then.
|
* would not be platform independent then.
|
||||||
*/
|
*/
|
||||||
XFlush(fgDisplay.Display);
|
XFlush(fgDisplay.Display);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,52 +195,55 @@ GLboolean fghChangeDisplayMode( GLboolean haveToTest )
|
|||||||
*/
|
*/
|
||||||
# ifdef X_XF86VidModeGetAllModeLines
|
# ifdef X_XF86VidModeGetAllModeLines
|
||||||
|
|
||||||
XF86VidModeModeInfo** displayModes;
|
if (fgDisplay.DisplayModeValid)
|
||||||
int i, displayModesCount;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Query for all the display available...
|
|
||||||
*/
|
|
||||||
XF86VidModeGetAllModeLines(
|
|
||||||
fgDisplay.Display,
|
|
||||||
fgDisplay.Screen,
|
|
||||||
&displayModesCount,
|
|
||||||
&displayModes
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check every of the modes looking for one that matches our demands
|
|
||||||
*/
|
|
||||||
for( i=0; i<displayModesCount; i++ )
|
|
||||||
{
|
{
|
||||||
if( fghCheckDisplayMode( displayModes[ i ]->hdisplay, displayModes[ i ]->vdisplay,
|
XF86VidModeModeInfo** displayModes;
|
||||||
fgState.GameModeDepth, fgState.GameModeRefresh ) )
|
int i, displayModesCount;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Query for all the display available...
|
||||||
|
*/
|
||||||
|
XF86VidModeGetAllModeLines(
|
||||||
|
fgDisplay.Display,
|
||||||
|
fgDisplay.Screen,
|
||||||
|
&displayModesCount,
|
||||||
|
&displayModes
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check every of the modes looking for one that matches our demands
|
||||||
|
*/
|
||||||
|
for( i=0; i<displayModesCount; i++ )
|
||||||
{
|
{
|
||||||
if( haveToTest )
|
if( fghCheckDisplayMode( displayModes[ i ]->hdisplay, displayModes[ i ]->vdisplay,
|
||||||
return( TRUE );
|
fgState.GameModeDepth, fgState.GameModeRefresh ) )
|
||||||
/*
|
{
|
||||||
* OKi, this is the display mode we have been looking for...
|
if( haveToTest )
|
||||||
*/
|
return( TRUE );
|
||||||
XF86VidModeSwitchToMode(
|
/*
|
||||||
fgDisplay.Display,
|
* OKi, this is the display mode we have been looking for...
|
||||||
fgDisplay.Screen,
|
*/
|
||||||
displayModes[ i ]
|
XF86VidModeSwitchToMode(
|
||||||
);
|
fgDisplay.Display,
|
||||||
|
fgDisplay.Screen,
|
||||||
|
displayModes[ i ]
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the viewport's origin to (0,0) (the game mode window's top-left corner)
|
* Set the viewport's origin to (0,0) (the game mode window's top-left corner)
|
||||||
*/
|
*/
|
||||||
XF86VidModeSetViewPort(
|
XF86VidModeSetViewPort(
|
||||||
fgDisplay.Display,
|
fgDisplay.Display,
|
||||||
fgDisplay.Screen,
|
fgDisplay.Screen,
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return successfull...
|
* Return successfull...
|
||||||
*/
|
*/
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user