diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp index dd7c77732bc..659579c7c29 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp @@ -486,7 +486,7 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) } #endif - DX8Wrapper::Set_Light_Environment(rinfo.light_environment); + Renderer::Set_Light_Environment(rinfo.light_environment); // Force shaders to update. m_stageTwoTexture->restore(); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp index 849035dcc13..0a008cfd7c0 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp @@ -1922,7 +1922,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) } #endif - DX8Wrapper::Set_Light_Environment(rinfo.light_environment); + Renderer::Set_Light_Environment(rinfo.light_environment); // Force shaders to update. m_stageTwoTexture->restore(); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp index b2e4e86aabc..ecb56bc1cbf 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp @@ -2377,10 +2377,10 @@ void WaterRenderObjClass::renderWaterMesh() DX8Wrapper::Set_Texture(0,setting->waterTexture); DX8Wrapper::Set_Texture(1,setting->waterTexture); - DX8Wrapper::Set_Light(0,*m_meshLight); - DX8Wrapper::Set_Light(1,nullptr); - DX8Wrapper::Set_Light(2,nullptr); - DX8Wrapper::Set_Light(3,nullptr); + Renderer::Set_Light(0,*m_meshLight); + Renderer::Clear_Light(1); + Renderer::Clear_Light(2); + Renderer::Clear_Light(3); /* DX8Wrapper::Set_DX8_Render_State(D3DRS_AMBIENT,0); //turn off scene ambient DX8Wrapper::Set_DX8_Render_State(D3DRS_SPECULARENABLE,TRUE); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp index 99497bf2a2e..66e812e9a4c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp @@ -218,3 +218,18 @@ void Renderer::Set_Light_Environment(LightEnvironmentClass * light_env) { DX8Wrapper::Set_Light_Environment(light_env); } + +void Renderer::Set_Light(unsigned index, const LightClass & light) +{ + DX8Wrapper::Set_Light(index, light); +} + +void Renderer::Clear_Light(unsigned index) +{ + DX8Wrapper::Set_Light(index, nullptr); +} + +void Renderer::Set_Fog(bool enable, const Vector3 & color, float start, float end) +{ + DX8Wrapper::Set_Fog(enable, color, start, end); +} diff --git a/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h b/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h index f81a2b48d74..8f90892f7d8 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h @@ -28,6 +28,7 @@ // Forward declarations keep this header includable without pulling in the full // WW3D2 header graph. All W3D classes below are passed by pointer or reference. +class LightClass; class LightEnvironmentClass; class Matrix3D; class Matrix4x4; @@ -93,4 +94,7 @@ class Renderer static void Set_Ambient(const Vector3 & color); static void Set_Light_Environment(LightEnvironmentClass * light_env); + static void Set_Light(unsigned index, const LightClass & light); + static void Clear_Light(unsigned index); + static void Set_Fog(bool enable, const Vector3 & color, float start, float end); }; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp index a1a6b6a1056..10b17cea73a 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp @@ -1805,7 +1805,7 @@ void DX8TextureCategoryClass::Render() LightEnvironmentClass * lenv = mesh->Get_Lighting_Environment(); if (lenv != nullptr) { SNAPSHOT_SAY(("LightEnvironment, lights: %d",lenv->Get_Light_Count())); - DX8Wrapper::Set_Light_Environment(lenv); + Renderer::Set_Light_Environment(lenv); } else { SNAPSHOT_SAY(("No light environment")); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp index 53de7a8bb57..d7086c2821a 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp @@ -972,7 +972,7 @@ void RTS3DScene::updatePlayerColorPasses() void RTS3DScene::Render(RenderInfoClass & rinfo) { //USE_PERF_TIMER(NonTerrainRender) - DX8Wrapper::Set_Fog(FogEnabled, FogColor, FogStart, FogEnd); + Renderer::Set_Fog(FogEnabled, FogColor, FogStart, FogEnd); //Override the behind building selection if it's not available on current hardware (needs stencil). TheWritableGlobalData->m_enableBehindBuildingMarkers = TheWritableGlobalData->m_enableBehindBuildingMarkers && Renderer::Has_Stencil(); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/mesh.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/mesh.cpp index eb60894d322..9545580b3de 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/mesh.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/mesh.cpp @@ -828,7 +828,7 @@ void MeshClass::Render_Material_Pass(MaterialPassClass * pass,IndexBufferClass * Vector3 oldEmissive(-1,-1,-1); if (LightEnvironment != nullptr) { - DX8Wrapper::Set_Light_Environment(LightEnvironment); + Renderer::Set_Light_Environment(LightEnvironment); } if (Model->Get_Flag(MeshModelClass::SKIN)) { diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp index 3e091867147..1e7a5e4c535 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp @@ -198,7 +198,7 @@ void SceneClass::Render(RenderInfoClass & rinfo) // Any stuff that needs to get done before anything else Pre_Render_Processing(rinfo); - DX8Wrapper::Set_Fog(FogEnabled, FogColor, FogStart, FogEnd); + Renderer::Set_Fog(FogEnabled, FogColor, FogStart, FogEnd); if (Get_Extra_Pass_Polygon_Mode()==EXTRA_PASS_DISABLE) { Customized_Render(rinfo); @@ -481,10 +481,10 @@ void SimpleSceneClass::Customized_Render(RenderInfoClass & rinfo) // derived classes should use light environment WWASSERT(rinfo.light_environment==nullptr); // Turn off lights in case we have none - DX8Wrapper::Set_Light(0,nullptr); - DX8Wrapper::Set_Light(1,nullptr); - DX8Wrapper::Set_Light(2,nullptr); - DX8Wrapper::Set_Light(3,nullptr); + Renderer::Clear_Light(0); + Renderer::Clear_Light(1); + Renderer::Clear_Light(2); + Renderer::Clear_Light(3); // (gth) WWShade only works with light environments. We need to upgrade LightEnvironment to // support real point lights, etc. It will likely just evolve into "the n most important" lights @@ -495,7 +495,7 @@ void SimpleSceneClass::Customized_Render(RenderInfoClass & rinfo) { if (count<4) { - DX8Wrapper::Set_Light(count,*(LightClass*)it.Peek_Obj()); + Renderer::Set_Light(count,*(LightClass*)it.Peek_Obj()); } else { // Simple scene only supports 4 global lights