Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(display): widescreen - offer native modes and widen the FOV per aspect

Olcay Seygandb2009f7e6b7
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
index 72df7e276..e44a8b085 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
@@ -506,9 +506,12 @@ 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.
- {
+ // Widescreen (PLAN.md Phase 6): the 4:3-only filter is gone - the camera
+ // now widens its FOV per aspect (W3DView::setWidth), so any mode the
+ // device offers above the floor is playable.
+ if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
+ && resolutions[res].Height >= MIN_DISPLAY_RESOLUTOIN_Y )
+ {
numResolutions++;
}
}
@@ -525,9 +528,10 @@ 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.
- {
+ // Same filter as getDisplayModeCount - the two must agree or indices shift.
+ if ( resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X
+ && resolutions[res].Height >= MIN_DISPLAY_RESOLUTOIN_Y )
+ {
if (numResolutions == modeIndex)
{ //found the mode
*xres=resolutions[res].Width;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
index 840a06a9d..c732831d0 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
@@ -229,7 +229,16 @@ void W3DView::setWidth(Int width)
//we want to maintain the same scale, so we'll need to adjust the fov.
//default W3D fov for full-screen is 50 degrees.
- m_3DCamera->Set_View_Plane((Real)width/(Real)TheDisplay->getWidth()*DEG_TO_RADF(50.0f),-1);
+ //Widescreen (PLAN.md Phase 6): 50 degrees is the *4:3* horizontal FOV. The
+ //camera derives the vertical extent as X/aspect, so a wider aspect with a
+ //fixed hfov crops the vertical view (vert-). Widen the hfov so the vertical
+ //view stays exactly what 4:3 shows and the extra screen shows more world
+ //horizontally (hor+). At 4:3 the factor is 1 and nothing changes.
+ Real hfov = (Real)width/(Real)TheDisplay->getWidth()*DEG_TO_RADF(50.0f);
+ Real aspect = (getHeight() > 0) ? (Real)width/(Real)getHeight() : (4.0f/3.0f);
+ if (aspect > (4.0f/3.0f))
+ hfov = 2.0f * (Real)atan( tan(hfov * 0.5f) * aspect / (4.0f/3.0f) );
+ m_3DCamera->Set_View_Plane(hfov,-1);
}
//-------------------------------------------------------------------------------------------------