Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions Core/GameEngine/Include/Common/OptionPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ class OptionPreferences : public UserPreferences
OptionPreferences();
virtual ~OptionPreferences() override;

enum AliasingMode CPP_11(: Int)
{
OFF = 0,
X2,
X4,
X8,
NUM_ALIASING_MODES
};

Bool loadFromIniFile();

UnsignedInt getAntiAliasing();
UnsignedInt getTextureFilterMode();
UnsignedInt getTextureAnisotropyLevel();
UnsignedInt getLANIPAddress();
UnsignedInt getOnlineIPAddress();
void setLANIPAddress(AsciiString IP);
Expand Down
68 changes: 68 additions & 0 deletions Core/GameEngine/Source/Common/OptionPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine

#include "ww3d.h"
#include "texturefilter.h"

#include "Common/AudioSettings.h"
#include "Common/GameAudio.h"
#include "Common/GameLOD.h"
Expand Down Expand Up @@ -66,6 +69,71 @@ Bool OptionPreferences::loadFromIniFile()
return load("Options.ini");
}

UnsignedInt OptionPreferences::getAntiAliasing()
{
OptionPreferences::const_iterator it = find("AntiAliasing");
if (it == end())
return WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE;

UnsignedInt level = atoi(it->second.str());
if (level == WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE)
level = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE;
else if (level <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_2X)
level = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_2X;
else if (level <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_4X)
level = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_4X;
else if (level <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X)
level = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X;

if (level > WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X)
level = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X;

return level;
}

UnsignedInt OptionPreferences::getTextureFilterMode()
{
OptionPreferences::const_iterator it = find("TextureFilter");
if (it == end())
return TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_BILINEAR;

UnsignedInt filter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_NONE;
if(stricmp(it->second.str(), "None") == 0)
filter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_NONE;
else if(stricmp(it->second.str(), "Point") == 0)
filter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_POINT;
else if (stricmp(it->second.str(), "Bilinear") == 0)
filter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_BILINEAR;
else if (stricmp(it->second.str(), "Trilinear") == 0)
filter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_TRILINEAR;
else if (stricmp(it->second.str(), "Anisotropic") == 0)
filter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_ANISOTROPIC;

return filter;
}

UnsignedInt OptionPreferences::getTextureAnisotropyLevel()
{
OptionPreferences::const_iterator it = find("AnisotropyLevel");
if (it == end())
return TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_2X;

UnsignedInt level = atoi(it->second.str());
if (level <= TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_2X)
level = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_2X;
else if (level <= TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_4X)
level = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_4X;
else if (level <= TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_8X)
level = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_8X;
else if (level <= TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_16X)
level = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_16X;

if (level > TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_16X)
level = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_16X;

return level;
}

Int OptionPreferences::getCampaignDifficulty()
{
OptionPreferences::const_iterator it = find("CampaignDifficulty");
Expand Down
8 changes: 4 additions & 4 deletions Core/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void TextureFilterClass::Apply(unsigned int stage)
//! Init filters (legacy)
/*!
*/
void TextureFilterClass::_Init_Filters(TextureFilterMode filter_type)
void TextureFilterClass::_Init_Filters(TextureFilterMode texture_filter, AnisotropicFilterMode anisotropy_level)
{
const D3DCAPS8& dx8caps=DX8Wrapper::Get_Current_Caps()->Get_DX8_Caps();

Expand All @@ -122,7 +122,7 @@ void TextureFilterClass::_Init_Filters(TextureFilterMode filter_type)
// TheSuperHackers @feature Mauller 08/03/2026 Add full support for all texture filtering modes;
// None, Point, Bilinear, Trilinear, Anisotropic.
BOOL FilterSupported = false;
switch (filter_type) {
switch (texture_filter) {

default:
// TheSuperHackers @info if we have an invalid filter_type, set the filtering to none
Expand Down Expand Up @@ -201,8 +201,8 @@ void TextureFilterClass::_Init_Filters(TextureFilterMode filter_type)
_MinTextureFilters[0][FILTER_TYPE_BEST]=D3DTEXF_ANISOTROPIC;
_MagTextureFilters[0][FILTER_TYPE_BEST]=D3DTEXF_ANISOTROPIC;

// Set the Anisotropic filtering level for all stages - 2X by default
_Set_Max_Anisotropy(TEXTURE_FILTER_ANISOTROPIC_2X);
// Set the Anisotropic filtering level for all stages
_Set_Max_Anisotropy(anisotropy_level);
}
else {
_MinTextureFilters[0][FILTER_TYPE_BEST]=D3DTEXF_POINT;
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/texturefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class TextureFilterClass
void Set_V_Addr_Mode(TxtAddrMode mode) { VAddressMode=mode; }

// These need to be called after device has been created
static void _Init_Filters(TextureFilterMode texture_filter);
static void _Init_Filters(TextureFilterMode texture_filter, AnisotropicFilterMode anisotropy_level);
static void _Set_Max_Anisotropy(AnisotropicFilterMode mode);

static void _Set_Default_Min_Filter(FilterType filter);
Expand Down
5 changes: 4 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ class GlobalData : public SubsystemInterface
units will always keep their formation. If it's <1.0, then the user must click a
smaller area within the rectangle to order the gather. */

Int m_antiAliasBoxValue; ///< value of selected antialias from combo box in options menu
UnsignedInt m_antiAliasLevel; ///< value of selected antialias level in the game options
UnsignedInt m_textureFilteringMode; ///< value related to TextureFilterClass::TextureFilterModeEnum
UnsignedInt m_textureAnisotropyLevel; ///< value related to TextureFilterClass::AnisotropicFilterMode

Bool m_languageFilterPref; ///< Bool if user wants to filter language
Bool m_loadScreenDemo; ///< Bool if true, run the loadscreen demo movie
Bool m_disableRender; ///< if true, no rendering!
Expand Down
11 changes: 10 additions & 1 deletion GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine

#include "ww3d.h"
#include "texturefilter.h"

#include "Common/GlobalData.h"

#define DEFINE_TERRAIN_LOD_NAMES
Expand Down Expand Up @@ -930,7 +933,9 @@ GlobalData::GlobalData()

m_standardPublicBones.clear();

m_antiAliasBoxValue = 0;
m_antiAliasLevel = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE;
m_textureFilteringMode = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_BILINEAR;
m_textureAnisotropyLevel = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_2X;

// m_languageFilterPref = false;
m_languageFilterPref = true;
Expand Down Expand Up @@ -1229,6 +1234,10 @@ void GlobalData::parseGameDataDefinition( INI* ini )
TheWritableGlobalData->m_playerInfoListFontSize = optionPref.getPlayerInfoListFontSize();
TheWritableGlobalData->m_showMoneyPerMinute = optionPref.getShowMoneyPerMinute();

TheWritableGlobalData->m_antiAliasLevel = optionPref.getAntiAliasing();
TheWritableGlobalData->m_textureFilteringMode = optionPref.getTextureFilterMode();
TheWritableGlobalData->m_textureAnisotropyLevel = optionPref.getTextureAnisotropyLevel();

Int val=optionPref.getGammaValue();
//generate a value between 0.6 and 2.0.
if (val < 50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include "GameClient/MessageBox.h"

#include "ww3d.h"
#include "texturefilter.h"

// This is for non-RC builds only!!!
#define VERBOSE_VERSION L"Release"
Expand Down Expand Up @@ -552,14 +553,73 @@ static void saveOptions()
//-------------------------------------------------------------------------------------------------
// antialiasing
GadgetComboBoxGetSelectedPos(comboBoxAntiAliasing, &index);
if( index >= 0 && TheGlobalData->m_antiAliasBoxValue != index )
if( index >= 0 && TheGlobalData )
{
TheWritableGlobalData->m_antiAliasBoxValue = index;
Int mode = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE;

// TheSuperHackers @info We are converting comboBox entry position to human readable value
switch (index) {
default:
case OptionPreferences::AliasingMode::OFF:
mode = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE;
break;
case OptionPreferences::AliasingMode::X2:
mode = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_2X;
break;
case OptionPreferences::AliasingMode::X4:
mode = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_4X;
break;
case OptionPreferences::AliasingMode::X8:
mode = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X;
break;
}

TheWritableGlobalData->m_antiAliasLevel = mode;
AsciiString prefString;
prefString.format("%d", index);
prefString.format("%d", mode);
(*pref)["AntiAliasing"] = prefString;
}

//-------------------------------------------------------------------------------------------------
// texture filter mode
val = pref->getTextureFilterMode();
if (val >= 0 && TheGlobalData)
{
TheWritableGlobalData->m_textureFilteringMode = val;

AsciiString prefString;

switch (val) {
case TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_NONE:
prefString = "None";
break;
case TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_POINT:
prefString = "Point";
break;
case TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_BILINEAR:
prefString = "Bilinear";
break;
case TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_TRILINEAR:
prefString = "Trilinear";
break;
case TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_ANISOTROPIC:
prefString = "Anisotropic";
break;
}

(*pref)["TextureFilter"] = prefString;
}

//-------------------------------------------------------------------------------------------------
// anisotropy level
val = pref->getTextureAnisotropyLevel();
if (val >= 0 && TheGlobalData)
{
TheWritableGlobalData->m_textureAnisotropyLevel = val;
AsciiString prefString;
prefString.format("%d", val);
(*pref)["AnisotropyLevel"] = prefString;
}

//-------------------------------------------------------------------------------------------------
// mouse mode
Expand Down Expand Up @@ -1024,14 +1084,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )

Color color = GameMakeColor(255,255,255,255);

enum AliasingMode CPP_11(: Int)
{
OFF = 0,
LOW,
HIGH,
NUM_ALIASING_MODES
};

initLabelVersion();

// Choose an IP address, then initialize the IP combo box
Expand Down Expand Up @@ -1135,18 +1187,30 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
GadgetComboBoxReset(comboBoxAntiAliasing);
AsciiString temp;
Int i=0;
for (; i < NUM_ALIASING_MODES; ++i)
for (; i < OptionPreferences::AliasingMode::NUM_ALIASING_MODES; ++i)
{
temp.format("GUI:AntiAliasing%d", i);
str = TheGameText->fetch( temp );
index = GadgetComboBoxAddEntry(comboBoxAntiAliasing, str, color);
}
Int val = atoi(selectedAliasingMode.str());
if( val < 0 || val > NUM_ALIASING_MODES )
Int pos = 0;

// TheSuperHackers @info We are converting from human readable value to comboBox entry position
if (val <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE)
pos = OptionPreferences::AliasingMode::OFF;
else if (val <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_2X)
pos = OptionPreferences::AliasingMode::X2;
else if (val <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_4X)
pos = OptionPreferences::AliasingMode::X4;
else if (val <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X)
pos = OptionPreferences::AliasingMode::X8;

if( val < 0 || val > WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_8X)
{
TheWritableGlobalData->m_antiAliasBoxValue = val = 0;
TheWritableGlobalData->m_antiAliasLevel = pos = 0;
}
GadgetComboBoxSetSelectedPos(comboBoxAntiAliasing, val);
GadgetComboBoxSetSelectedPos(comboBoxAntiAliasing, pos);

// get resolution from saved preferences file
AsciiString selectedResolution = (*pref) ["Resolution"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ void W3DDisplay::init()
}

// TheSuperHackers @feature Mauller 13/03/2026 Add native MSAA support, must be set before creating render device
WW3D::Set_MSAA_Mode(WW3D::MULTISAMPLE_MODE_NONE);
WW3D::Set_MSAA_Mode((WW3D::MultiSampleModeEnum)TheWritableGlobalData->m_antiAliasLevel);

renderDeviceError = WW3D::Set_Render_Device(
0,
Expand All @@ -772,6 +772,14 @@ void W3DDisplay::init()
getWindowed(),
true );

// TheSuperHackers @info Update the MSAA mode that was set as some GPU's may not support certain levels
// Texture filtering must be also be updated after render device initialisation
TheWritableGlobalData->m_antiAliasLevel = (UnsignedInt)WW3D::Get_MSAA_Mode();
WW3D::Set_Texture_Filter(TheWritableGlobalData->m_textureFilteringMode);
TheWritableGlobalData->m_textureFilteringMode = WW3D::Get_Texture_Filter();
WW3D::Set_Anisotropy_level(TheWritableGlobalData->m_textureAnisotropyLevel);
TheWritableGlobalData->m_textureAnisotropyLevel = WW3D::Get_Anisotropy_level();

++attempt;
}
while (attempt < 3 && renderDeviceError != WW3D_ERROR_OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ void DX8Wrapper::Do_Onetime_Device_Dependent_Inits()
** Initialize any other subsystems inside of WW3D
*/
MissingTexture::_Init();
TextureFilterClass::_Init_Filters((TextureFilterClass::TextureFilterMode)WW3D::Get_Texture_Filter());
TextureFilterClass::_Init_Filters(
(TextureFilterClass::TextureFilterMode)WW3D::Get_Texture_Filter(),
(TextureFilterClass::AnisotropicFilterMode)WW3D::Get_Anisotropy_level()
);
TheDX8MeshRenderer.Init();
SHD_INIT;
BoxRenderObjClass::Init();
Expand Down
23 changes: 22 additions & 1 deletion GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
**
***********************************************************************************/

float WW3D::LogicFrameTimeMs = 1000.0f / WWSyncPerSecond; // initialized to something to avoid division by zero on first use

Check warning on line 164 in GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-debug+t+e

operator '/': deprecated between enumerations and floating-point types

Check warning on line 164 in GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-vcpkg-debug+t+e

operator '/': deprecated between enumerations and floating-point types

Check warning on line 164 in GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-profile+t+e

operator '/': deprecated between enumerations and floating-point types

Check warning on line 164 in GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32+t+e

operator '/': deprecated between enumerations and floating-point types

Check warning on line 164 in GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-vcpkg-profile+t+e

operator '/': deprecated between enumerations and floating-point types

Check warning on line 164 in GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp

View workflow job for this annotation

GitHub Actions / Build GeneralsMD / win32-vcpkg+t+e

operator '/': deprecated between enumerations and floating-point types
float WW3D::FractionalSyncMs = 0.0f;
unsigned int WW3D::SyncTime = 0;
unsigned int WW3D::PreviousSyncTime = 0;
Expand Down Expand Up @@ -223,6 +223,7 @@
int WW3D::LastFrameMemoryFrees;

int WW3D::TextureFilter = TextureFilterClass::TextureFilterMode::TEXTURE_FILTER_BILINEAR;
int WW3D::AnisotropyLevel = TextureFilterClass::AnisotropicFilterMode::TEXTURE_FILTER_ANISOTROPIC_2X;

bool WW3D::Lite = false;

Expand Down Expand Up @@ -768,9 +769,29 @@
if (texture_filter<0) texture_filter=0;
if (texture_filter>TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC) texture_filter=TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC;
TextureFilter=texture_filter;
TextureFilterClass::_Init_Filters((TextureFilterClass::TextureFilterMode)TextureFilter);
TextureFilterClass::_Init_Filters(
(TextureFilterClass::TextureFilterMode)TextureFilter,
(TextureFilterClass::AnisotropicFilterMode)AnisotropyLevel
);
}

void WW3D::Set_Anisotropy_level(int level)
{
if (level <= TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_2X)
level = TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_2X;
else if(level <= TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_4X)
level = TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_4X;
else if (level <= TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_8X)
level = TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_8X;
else if (level <= TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_16X)
level = TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_16X;

if (level > TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_16X)
level = TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC_16X;

AnisotropyLevel = level;
TextureFilterClass::_Set_Max_Anisotropy((TextureFilterClass::AnisotropicFilterMode)AnisotropyLevel);
}

/***********************************************************************************************
* WW3D::Begin_Render -- mark the start of rendering for a new frame *
Expand Down
Loading
Loading