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.

fix(ww3d2): stop padding long thin textures to a 2002 card's limit

Olcay Seygan298487137c3d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83c9945ba..5acaa8169 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -181,6 +181,7 @@ found and fixed — EA's own, not port damage.**
## Sharper textures, for free
- 481 base-game textures at four times the resolution now beat Zero Hour's downscaled copies.
+- A long thin texture loads at the size it was drawn at. Anything wider than eight to one used to be stretched onto a bigger, blurrier one, because that was the limit of a 2002 graphics card; the card is asked now, and modern ones have no such limit.
## Every replay, not just the last one
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp
index 4886e80a7..561be2870 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp
@@ -408,18 +408,26 @@ void TextureLoader::Validate_Texture_Size
poweroftwodepth=dx8caps.MaxVolumeExtent;
}
- if (poweroftwowidth>poweroftwoheight)
- {
- while (poweroftwowidth/poweroftwoheight>8)
+ // A texture wider than 8:1 used to be padded out until it was not, because that was what the
+ // cards of 2002 could hold. Ask the device instead: it reports its own limit, and 0 means it
+ // has none - so a long thin texture loads at the size it was drawn at rather than being
+ // stretched onto a bigger, blurrier one.
+ const unsigned maxTextureAspectRatio = dx8caps.MaxTextureAspectRatio;
+ if (maxTextureAspectRatio != 0)
+ {
+ if (poweroftwowidth>poweroftwoheight)
{
- poweroftwoheight*=2;
+ while ((unsigned)(poweroftwowidth/poweroftwoheight)>maxTextureAspectRatio)
+ {
+ poweroftwoheight*=2;
+ }
}
- }
- else
- {
- while (poweroftwoheight/poweroftwowidth>8)
+ else
{
- poweroftwowidth*=2;
+ while ((unsigned)(poweroftwoheight/poweroftwowidth)>maxTextureAspectRatio)
+ {
+ poweroftwowidth*=2;
+ }
}
}