Skip to content

[GEN][ZH] Allow selecting resolutions with aspect ratios different from 4:3 #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -419,6 +419,15 @@ W3DDisplay::~W3DDisplay()

} // end ~W3DDisplay

// TheSuperHackers @tweak valeronm 20/03/2025 Only accept 24-bit modes with min width 800
inline Bool isResolutionSupported(const ResolutionDescClass &res)
{
static const Int minWidth = 800;
static const Int minBitDepth = 24;

return res.Width >= minWidth && res.BitDepth >= minBitDepth;
}

/*Return number of screen modes supported by the current device*/
Int W3DDisplay::getDisplayModeCount(void)
{
@@ -442,8 +451,8 @@ Int W3DDisplay::getDisplayModeCount(void)
for (int res = 0; res < resolutions.Count (); res ++)
{
// Is this the resolution we are looking for?
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.
{
if (isResolutionSupported(resolutions[res]))
{
numResolutions++;
}
}
@@ -460,7 +469,7 @@ void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres,
for (int res = 0; res < resolutions.Count (); res ++)
{
// Is this the resolution we are looking for?
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.
if (isResolutionSupported(resolutions[res]))
{
if (numResolutions == modeIndex)
{ //found the mode
Original file line number Diff line number Diff line change
@@ -468,20 +468,14 @@ W3DDisplay::~W3DDisplay()

} // end ~W3DDisplay

#define MIN_DISPLAY_RESOLUTION_X 800
#define MIN_DISPLAY_RESOLUTOIN_Y 600


Bool IS_FOUR_BY_THREE_ASPECT( Real x, Real y )
// TheSuperHackers @tweak valeronm 20/03/2025 Only accept 24-bit modes with min width 800
inline Bool isResolutionSupported(const ResolutionDescClass &res)
{
if ( y == 0 )
return FALSE;

Real aspectRatio = fabs( x / y );
return (( aspectRatio > 1.332f) && ( aspectRatio < 1.334f));

}
static const Int minWidth = 800;
static const Int minBitDepth = 24;

return res.Width >= minWidth && res.BitDepth >= minBitDepth;
}

/*Return number of screen modes supported by the current device*/
Int W3DDisplay::getDisplayModeCount(void)
@@ -506,8 +500,7 @@ Int W3DDisplay::getDisplayModeCount(void)
for (int res = 0; res < resolutions.Count (); res ++)
{
// Is this the resolution we are looking for?
if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
&& IS_FOUR_BY_THREE_ASPECT( (Real)resolutions[res].Width, (Real)resolutions[res].Height ) ) //only accept 4:3 aspect ratio modes.
if (isResolutionSupported(resolutions[res]))
{
numResolutions++;
}
@@ -525,8 +518,7 @@ void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres,
for (int res = 0; res < resolutions.Count (); res ++)
{
// Is this the resolution we are looking for?
if ( resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
&& IS_FOUR_BY_THREE_ASPECT( (Real)resolutions[res].Width, (Real)resolutions[res].Height ) ) //only accept 4:3 aspect ratio modes.
if (isResolutionSupported(resolutions[res]))
{
if (numResolutions == modeIndex)
{ //found the mode