Skip to content

Commit 762b7af

Browse files
authored
[GEN][ZH] Enable resolutions with aspect ratios different from 4:3 in Options Menu (#460)
1 parent 25bd33e commit 762b7af

File tree

2 files changed

+18
-16
lines changed
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient

2 files changed

+18
-16
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ W3DDisplay::~W3DDisplay()
432432

433433
} // end ~W3DDisplay
434434

435+
// TheSuperHackers @tweak valeronm 20/03/2025 No longer filters resolutions by a 4:3 aspect ratio.
436+
inline Bool isResolutionSupported(const ResolutionDescClass &res)
437+
{
438+
static const Int minBitDepth = 24;
439+
440+
return res.Width >= MIN_DISPLAY_RESOLUTION_X && res.BitDepth >= minBitDepth;
441+
}
442+
435443
/*Return number of screen modes supported by the current device*/
436444
Int W3DDisplay::getDisplayModeCount(void)
437445
{
@@ -455,8 +463,8 @@ Int W3DDisplay::getDisplayModeCount(void)
455463
for (int res = 0; res < resolutions.Count (); res ++)
456464
{
457465
// Is this the resolution we are looking for?
458-
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.
459-
{
466+
if (isResolutionSupported(resolutions[res]))
467+
{
460468
numResolutions++;
461469
}
462470
}
@@ -473,7 +481,7 @@ void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres,
473481
for (int res = 0; res < resolutions.Count (); res ++)
474482
{
475483
// Is this the resolution we are looking for?
476-
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.
484+
if (isResolutionSupported(resolutions[res]))
477485
{
478486
if (numResolutions == modeIndex)
479487
{ //found the mode

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -481,17 +481,13 @@ W3DDisplay::~W3DDisplay()
481481

482482
} // end ~W3DDisplay
483483

484-
485-
Bool IS_FOUR_BY_THREE_ASPECT( Real x, Real y )
484+
// TheSuperHackers @tweak valeronm 20/03/2025 No longer filters resolutions by a 4:3 aspect ratio.
485+
inline Bool isResolutionSupported(const ResolutionDescClass &res)
486486
{
487-
if ( y == 0 )
488-
return FALSE;
489-
490-
Real aspectRatio = fabs( x / y );
491-
return (( aspectRatio > 1.332f) && ( aspectRatio < 1.334f));
492-
493-
}
487+
static const Int minBitDepth = 24;
494488

489+
return res.Width >= MIN_DISPLAY_RESOLUTION_X && res.BitDepth >= minBitDepth;
490+
}
495491

496492
/*Return number of screen modes supported by the current device*/
497493
Int W3DDisplay::getDisplayModeCount(void)
@@ -516,8 +512,7 @@ Int W3DDisplay::getDisplayModeCount(void)
516512
for (int res = 0; res < resolutions.Count (); res ++)
517513
{
518514
// Is this the resolution we are looking for?
519-
if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
520-
&& IS_FOUR_BY_THREE_ASPECT( (Real)resolutions[res].Width, (Real)resolutions[res].Height ) ) //only accept 4:3 aspect ratio modes.
515+
if (isResolutionSupported(resolutions[res]))
521516
{
522517
numResolutions++;
523518
}
@@ -535,8 +530,7 @@ void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres,
535530
for (int res = 0; res < resolutions.Count (); res ++)
536531
{
537532
// Is this the resolution we are looking for?
538-
if ( resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
539-
&& IS_FOUR_BY_THREE_ASPECT( (Real)resolutions[res].Width, (Real)resolutions[res].Height ) ) //only accept 4:3 aspect ratio modes.
533+
if (isResolutionSupported(resolutions[res]))
540534
{
541535
if (numResolutions == modeIndex)
542536
{ //found the mode

0 commit comments

Comments
 (0)