From 4f556f9516a01bd52e31d6c46484ef612bc5f0ca Mon Sep 17 00:00:00 2001 From: fayjf Date: Sun, 13 Mar 2011 21:00:37 +0000 Subject: [PATCH] Fixing game mode in Windows so that it doesn't override unspecified settings per e-mail from Diederick C. Niehorster, 1/25/2011, 11:09 PM. I think this addresses bug report 3112718. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@892 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/freeglut_gamemode.c | 29 +++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/freeglut/freeglut/src/freeglut_gamemode.c b/freeglut/freeglut/src/freeglut_gamemode.c index 3172dfc..24a8be1 100644 --- a/freeglut/freeglut/src/freeglut_gamemode.c +++ b/freeglut/freeglut/src/freeglut_gamemode.c @@ -324,13 +324,28 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest ) success = GL_FALSE; EnumDisplaySettings( fgDisplay.DisplayName, -1, &devMode ); - devMode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + devMode.dmFields = 0; - devMode.dmPelsWidth = fgState.GameModeSize.X; - devMode.dmPelsHeight = fgState.GameModeSize.Y; - devMode.dmBitsPerPel = fgState.GameModeDepth; - devMode.dmDisplayFrequency = fgState.GameModeRefresh; - devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + 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; + } switch ( ChangeDisplaySettingsEx(fgDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) ) { @@ -380,7 +395,7 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest ) */ void FGAPIENTRY glutGameModeString( const char* string ) { - int width = 640, height = 480, depth = 16, refresh = 72; + int width = -1, height = -1, depth = -1, refresh = -1; FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );