Skip to content

Commit 6dc2258

Browse files
committed
Improve logic
1 parent e6298c2 commit 6dc2258

File tree

2 files changed

+44
-12
lines changed
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient

2 files changed

+44
-12
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,15 +685,31 @@ void W3DDisplay::init( void )
685685
setBitDepth( 16 );
686686
break;
687687
case 2:
688+
{
688689
// TheSuperHackers @bugfix xezon 11/06/2025 Now tries a safe default resolution
689-
// if the previous one did not succeed. This is unlikely to happen but is possible
690-
// if the user writes an unsupported resolution into to the Option Preferences.
691-
TheWritableGlobalData->m_xResolution = 800;
692-
TheWritableGlobalData->m_yResolution = 600;
693-
setWidth( TheGlobalData->m_xResolution );
694-
setHeight( TheGlobalData->m_yResolution );
690+
// if the custom resolution did not succeed. This is unlikely to happen but is possible
691+
// if the user writes an unsupported resolution into to the Option Preferences or if the
692+
// graphics adapter does not support 800 x 600 to begin with.
693+
const Int minW = 800;
694+
const Int minH = 600;
695+
Int xres = minW;
696+
Int yres = minH;
697+
Int bitDepth = 32;
698+
Int displayModeCount = getDisplayModeCount();
699+
Int displayModeIndex = 0;
700+
for (; displayModeIndex < displayModeCount; ++displayModeIndex)
701+
{
702+
getDisplayModeDescription(0, &xres, &yres, &bitDepth);
703+
if (xres * yres >= minW * minH)
704+
break; // Is good enough. Use it.
705+
}
706+
TheWritableGlobalData->m_xResolution = xres;
707+
TheWritableGlobalData->m_yResolution = yres;
708+
setWidth( xres );
709+
setHeight( yres );
695710
setBitDepth( 32 );
696711
break;
712+
}
697713
case 3:
698714
setBitDepth( 16 );
699715
break;

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,15 +752,31 @@ void W3DDisplay::init( void )
752752
setBitDepth( 16 );
753753
break;
754754
case 2:
755+
{
755756
// TheSuperHackers @bugfix xezon 11/06/2025 Now tries a safe default resolution
756-
// if the previous one did not succeed. This is unlikely to happen but is possible
757-
// if the user writes an unsupported resolution into to the Option Preferences.
758-
TheWritableGlobalData->m_xResolution = 800;
759-
TheWritableGlobalData->m_yResolution = 600;
760-
setWidth( TheGlobalData->m_xResolution );
761-
setHeight( TheGlobalData->m_yResolution );
757+
// if the custom resolution did not succeed. This is unlikely to happen but is possible
758+
// if the user writes an unsupported resolution into to the Option Preferences or if the
759+
// graphics adapter does not support 800 x 600 to begin with.
760+
const Int minW = 800;
761+
const Int minH = 600;
762+
Int xres = minW;
763+
Int yres = minH;
764+
Int bitDepth = 32;
765+
Int displayModeCount = getDisplayModeCount();
766+
Int displayModeIndex = 0;
767+
for (; displayModeIndex < displayModeCount; ++displayModeIndex)
768+
{
769+
getDisplayModeDescription(0, &xres, &yres, &bitDepth);
770+
if (xres * yres >= minW * minH)
771+
break; // Is good enough. Use it.
772+
}
773+
TheWritableGlobalData->m_xResolution = xres;
774+
TheWritableGlobalData->m_yResolution = yres;
775+
setWidth( xres );
776+
setHeight( yres );
762777
setBitDepth( 32 );
763778
break;
779+
}
764780
case 3:
765781
setBitDepth( 16 );
766782
break;

0 commit comments

Comments
 (0)