Skip to content

Commit 56e614b

Browse files
committed
Allow to select all resolutions supported by display
1 parent 45b45cb commit 56e614b

File tree

2 files changed

+20
-19
lines changed
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient

2 files changed

+20
-19
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ W3DDisplay::~W3DDisplay()
419419

420420
} // end ~W3DDisplay
421421

422+
// TheSuperHackers @tweak valeronm 20/03/2025 Only accept 24-bit modes with min width 800
423+
inline Bool isResolutionSupported(const ResolutionDescClass &res)
424+
{
425+
static const Int minWidth = 800;
426+
static const Int minBitDepth = 24;
427+
428+
return res.Width >= minWidth && res.BitDepth >= minBitDepth;
429+
}
430+
422431
/*Return number of screen modes supported by the current device*/
423432
Int W3DDisplay::getDisplayModeCount(void)
424433
{
@@ -442,8 +451,8 @@ Int W3DDisplay::getDisplayModeCount(void)
442451
for (int res = 0; res < resolutions.Count (); res ++)
443452
{
444453
// Is this the resolution we are looking for?
445-
if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= 800 && (fabs((Real)resolutions[res].Width/(Real)resolutions[res].Height - 1.3333f)) < 0.01f) //only accept 4:3 aspect ratio modes.
446-
{
454+
if (isResolutionSupported(resolutions[res]))
455+
{
447456
numResolutions++;
448457
}
449458
}
@@ -460,7 +469,7 @@ void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres,
460469
for (int res = 0; res < resolutions.Count (); res ++)
461470
{
462471
// Is this the resolution we are looking for?
463-
if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= 800 && (fabs((Real)resolutions[res].Width/(Real)resolutions[res].Height - 1.3333f)) < 0.01f) //only accept 4:3 aspect ratio modes.
472+
if (isResolutionSupported(resolutions[res]))
464473
{
465474
if (numResolutions == modeIndex)
466475
{ //found the mode

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -468,20 +468,14 @@ W3DDisplay::~W3DDisplay()
468468

469469
} // end ~W3DDisplay
470470

471-
#define MIN_DISPLAY_RESOLUTION_X 800
472-
#define MIN_DISPLAY_RESOLUTOIN_Y 600
473-
474-
475-
Bool IS_FOUR_BY_THREE_ASPECT( Real x, Real y )
471+
// TheSuperHackers @tweak valeronm 20/03/2025 Only accept 24-bit modes with min width 800
472+
inline Bool isResolutionSupported(const ResolutionDescClass &res)
476473
{
477-
if ( y == 0 )
478-
return FALSE;
479-
480-
Real aspectRatio = fabs( x / y );
481-
return (( aspectRatio > 1.332f) && ( aspectRatio < 1.334f));
482-
483-
}
474+
static const Int minWidth = 800;
475+
static const Int minBitDepth = 24;
484476

477+
return res.Width >= minWidth && res.BitDepth >= minBitDepth;
478+
}
485479

486480
/*Return number of screen modes supported by the current device*/
487481
Int W3DDisplay::getDisplayModeCount(void)
@@ -506,8 +500,7 @@ Int W3DDisplay::getDisplayModeCount(void)
506500
for (int res = 0; res < resolutions.Count (); res ++)
507501
{
508502
// Is this the resolution we are looking for?
509-
if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
510-
&& IS_FOUR_BY_THREE_ASPECT( (Real)resolutions[res].Width, (Real)resolutions[res].Height ) ) //only accept 4:3 aspect ratio modes.
503+
if (isResolutionSupported(resolutions[res]))
511504
{
512505
numResolutions++;
513506
}
@@ -525,8 +518,7 @@ void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres,
525518
for (int res = 0; res < resolutions.Count (); res ++)
526519
{
527520
// Is this the resolution we are looking for?
528-
if ( resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
529-
&& IS_FOUR_BY_THREE_ASPECT( (Real)resolutions[res].Width, (Real)resolutions[res].Height ) ) //only accept 4:3 aspect ratio modes.
521+
if (isResolutionSupported(resolutions[res]))
530522
{
531523
if (numResolutions == modeIndex)
532524
{ //found the mode

0 commit comments

Comments
 (0)