when entering game mode, now avoiding call to ChangeDisplaySettingsEx
when not necessary. Avoids flashing of the screen git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1453 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
2de980d6b4
commit
d01664a8bf
@ -29,74 +29,47 @@
|
||||
#include "../fg_internal.h"
|
||||
|
||||
/*
|
||||
* Remembers the current visual settings, so that
|
||||
* we can change them and restore later...
|
||||
*
|
||||
*
|
||||
*/
|
||||
void fgPlatformRememberState( void )
|
||||
{
|
||||
/* Grab the current desktop settings... */
|
||||
|
||||
/* hack to get around my stupid cross-gcc headers */
|
||||
#define FREEGLUT_ENUM_CURRENT_SETTINGS -1
|
||||
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS,
|
||||
&fgDisplay.pDisplay.DisplayMode );
|
||||
|
||||
/* Make sure we will be restoring all settings needed */
|
||||
fgDisplay.pDisplay.DisplayMode.dmFields |=
|
||||
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores the previously remembered visual settings
|
||||
*/
|
||||
void fgPlatformRestoreState( void )
|
||||
{
|
||||
/* Restore the previously remembered desktop display settings */
|
||||
ChangeDisplaySettingsEx( fgDisplay.pDisplay.DisplayName,&fgDisplay.pDisplay.DisplayMode, 0,0,0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Changes the current display mode to match user's settings
|
||||
*/
|
||||
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
GLboolean fghPlatformChangeDisplayMode(GLboolean haveToTest, DEVMODE *devModeRequested)
|
||||
{
|
||||
GLboolean success = GL_FALSE;
|
||||
DEVMODE devMode;
|
||||
DEVMODE devModeCurrent;
|
||||
char *fggmstr = NULL;
|
||||
char displayMode[300];
|
||||
|
||||
success = GL_FALSE;
|
||||
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, -1, &devMode );
|
||||
devMode.dmFields = 0;
|
||||
|
||||
if (fgState.GameModeSize.X!=-1)
|
||||
/* Get current display mode */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, ENUM_CURRENT_SETTINGS, &devModeCurrent );
|
||||
/* Now see if requested matches current mode, then we're done
|
||||
* There's only four fields we touch:
|
||||
* - dmPelsWidth
|
||||
* - dmPelsHeight
|
||||
* - dmBitsPerPel
|
||||
* - dmDisplayFrequency
|
||||
*/
|
||||
if (devModeCurrent.dmPelsWidth ==devModeRequested->dmPelsWidth &&
|
||||
devModeCurrent.dmPelsHeight ==devModeRequested->dmPelsHeight &&
|
||||
devModeCurrent.dmBitsPerPel ==devModeRequested->dmBitsPerPel &&
|
||||
devModeCurrent.dmDisplayFrequency==devModeRequested->dmDisplayFrequency)
|
||||
{
|
||||
devMode.dmPelsWidth = fgState.GameModeSize.X;
|
||||
devMode.dmFields |= DM_PELSWIDTH;
|
||||
}
|
||||
if (fgState.GameModeSize.Y!=-1)
|
||||
if (!haveToTest)
|
||||
{
|
||||
devMode.dmPelsHeight = fgState.GameModeSize.Y;
|
||||
devMode.dmFields |= DM_PELSHEIGHT;
|
||||
}
|
||||
if (fgState.GameModeDepth!=-1)
|
||||
{
|
||||
devMode.dmBitsPerPel = fgState.GameModeDepth;
|
||||
devMode.dmFields |= DM_BITSPERPEL;
|
||||
}
|
||||
if (fgState.GameModeRefresh!=-1)
|
||||
{
|
||||
devMode.dmDisplayFrequency = fgState.GameModeRefresh;
|
||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
/* update vars in case if actual switch was requested */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, ENUM_CURRENT_SETTINGS, &devModeCurrent );
|
||||
fgState.GameModeSize.X = devModeCurrent.dmPelsWidth;
|
||||
fgState.GameModeSize.Y = devModeCurrent.dmPelsHeight;
|
||||
fgState.GameModeDepth = devModeCurrent.dmBitsPerPel;
|
||||
fgState.GameModeRefresh = devModeCurrent.dmDisplayFrequency;
|
||||
}
|
||||
|
||||
switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
|
||||
/* We're done */
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Ok, we do have a mode switch to perform/test */
|
||||
switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, devModeRequested, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
|
||||
{
|
||||
case DISP_CHANGE_SUCCESSFUL:
|
||||
success = GL_TRUE;
|
||||
@ -104,11 +77,11 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
if (!haveToTest)
|
||||
{
|
||||
/* update vars in case if windows switched to proper mode */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
|
||||
fgState.GameModeSize.X = devMode.dmPelsWidth;
|
||||
fgState.GameModeSize.Y = devMode.dmPelsHeight;
|
||||
fgState.GameModeDepth = devMode.dmBitsPerPel;
|
||||
fgState.GameModeRefresh = devMode.dmDisplayFrequency;
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, ENUM_CURRENT_SETTINGS, &devModeCurrent );
|
||||
fgState.GameModeSize.X = devModeCurrent.dmPelsWidth;
|
||||
fgState.GameModeSize.Y = devModeCurrent.dmPelsHeight;
|
||||
fgState.GameModeDepth = devModeCurrent.dmBitsPerPel;
|
||||
fgState.GameModeRefresh = devModeCurrent.dmDisplayFrequency;
|
||||
}
|
||||
break;
|
||||
case DISP_CHANGE_RESTART:
|
||||
@ -134,16 +107,79 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
if ( !success )
|
||||
{
|
||||
/* I'd rather get info whats going on in my program than wonder about */
|
||||
/* magic happenings behind my back, its lib for devels at last ;) */
|
||||
/* what magic happens behind my back, its lib for devels after all ;) */
|
||||
|
||||
/* append display mode to error to make things more informative */
|
||||
sprintf(displayMode,"%s Problem with requested mode: %lux%lu:%lu@%lu", fggmstr, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmDisplayFrequency);
|
||||
sprintf(displayMode,"%s Problem with requested mode: %lux%lu:%lu@%lu", fggmstr, devModeRequested->dmPelsWidth, devModeRequested->dmPelsHeight, devModeRequested->dmBitsPerPel, devModeRequested->dmDisplayFrequency);
|
||||
fgWarning(displayMode);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remembers the current visual settings, so that
|
||||
* we can change them and restore later...
|
||||
*/
|
||||
void fgPlatformRememberState( void )
|
||||
{
|
||||
/* Grab the current desktop settings... */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, ENUM_CURRENT_SETTINGS,
|
||||
&fgDisplay.pDisplay.DisplayMode );
|
||||
|
||||
/* Make sure we will be restoring all settings needed */
|
||||
fgDisplay.pDisplay.DisplayMode.dmFields |=
|
||||
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores the previously remembered visual settings
|
||||
*/
|
||||
void fgPlatformRestoreState( void )
|
||||
{
|
||||
/* Restore the previously remembered desktop display settings */
|
||||
fghPlatformChangeDisplayMode(GL_FALSE,&fgDisplay.pDisplay.DisplayMode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Changes the current display mode to match user's settings
|
||||
*/
|
||||
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
{
|
||||
DEVMODE devMode;
|
||||
|
||||
/* Get current display mode */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, ENUM_CURRENT_SETTINGS, &devMode );
|
||||
devMode.dmFields = 0;
|
||||
|
||||
if (fgState.GameModeSize.X!=-1)
|
||||
{
|
||||
devMode.dmPelsWidth = fgState.GameModeSize.X;
|
||||
devMode.dmFields |= DM_PELSWIDTH;
|
||||
}
|
||||
if (fgState.GameModeSize.Y!=-1)
|
||||
{
|
||||
devMode.dmPelsHeight = fgState.GameModeSize.Y;
|
||||
devMode.dmFields |= DM_PELSHEIGHT;
|
||||
}
|
||||
if (fgState.GameModeDepth!=-1)
|
||||
{
|
||||
devMode.dmBitsPerPel = fgState.GameModeDepth;
|
||||
devMode.dmFields |= DM_BITSPERPEL;
|
||||
}
|
||||
if (fgState.GameModeRefresh!=-1)
|
||||
{
|
||||
devMode.dmDisplayFrequency = fgState.GameModeRefresh;
|
||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
|
||||
return fghPlatformChangeDisplayMode(haveToTest, &devMode);
|
||||
}
|
||||
|
||||
void fgPlatformEnterGameMode( void )
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user