diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp index 4cbe7db3bad..a5ddf476d8f 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp @@ -83,6 +83,7 @@ #include "W3DDevice/GameClient/W3DWater.h" #include "W3DDevice/GameClient/W3DShroud.h" #include "WW3D2/dx8wrapper.h" +#include "WW3D2/Renderer.h" #include "WW3D2/light.h" #include "WW3D2/scene.h" #include "W3DDevice/GameClient/W3DPoly.h" @@ -2296,7 +2297,7 @@ void BaseHeightMapRenderObjClass::renderShoreLines(CameraClass *pCamera) return; //Check if video card is capable of using this effect - if (DX8Wrapper::getBackBufferFormat() != WW3D_FORMAT_A8R8G8B8) + if (Renderer::Get_Back_Buffer_Format() != WW3D_FORMAT_A8R8G8B8) return; //can't apply effect on cards without destination alpha Int vertexCount = 0; @@ -2461,7 +2462,7 @@ void BaseHeightMapRenderObjClass::renderShoreLinesSorted(CameraClass *pCamera) return; //Check if video card is capable of using this effect - if (DX8Wrapper::getBackBufferFormat() != WW3D_FORMAT_A8R8G8B8) + if (Renderer::Get_Back_Buffer_Format() != WW3D_FORMAT_A8R8G8B8) return; //can't apply effect on cards without destination alpha Int vertexCount = 0; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp index 0dc03cfb1bb..ee43be22b7f 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp @@ -82,6 +82,7 @@ #include "W3DDevice/GameClient/W3DWater.h" #include "W3DDevice/GameClient/W3DShroud.h" #include "WW3D2/dx8wrapper.h" +#include "WW3D2/Renderer.h" #include "WW3D2/light.h" #include "WW3D2/scene.h" #include "W3DDevice/GameClient/W3DPoly.h" @@ -537,7 +538,7 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) W3DShaderManager::setTexture(2,m_stageTwoTexture); //cloud W3DShaderManager::setTexture(3,m_stageThreeTexture);//noise //Disable writes to destination alpha channel (if there is one) - if (DX8Wrapper::getBackBufferFormat() == WW3D_FORMAT_A8R8G8B8) { + if (Renderer::Get_Back_Buffer_Format() == WW3D_FORMAT_A8R8G8B8) { DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp index cea9b8e7275..749daaafa88 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp @@ -83,6 +83,7 @@ #include "W3DDevice/GameClient/W3DWater.h" #include "W3DDevice/GameClient/W3DShroud.h" #include "WW3D2/dx8wrapper.h" +#include "WW3D2/Renderer.h" #include "WW3D2/light.h" #include "WW3D2/scene.h" #include "W3DDevice/GameClient/W3DPoly.h" @@ -2019,7 +2020,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) W3DShaderManager::setTexture(2,m_stageTwoTexture); //cloud W3DShaderManager::setTexture(3,m_stageThreeTexture);//noise //Disable writes to destination alpha channel (if there is one) - if (DX8Wrapper::getBackBufferFormat() == WW3D_FORMAT_A8R8G8B8) + if (Renderer::Get_Back_Buffer_Format() == WW3D_FORMAT_A8R8G8B8) DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp index 61119fefd09..ff6bb00e4f2 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp @@ -2937,7 +2937,7 @@ VideoBuffer* W3DDisplay::createVideoBuffer() // first try to use the native format - WW3DFormat displayFormat = DX8Wrapper::getBackBufferFormat(); + WW3DFormat displayFormat = Renderer::Get_Back_Buffer_Format(); if ( DX8Wrapper::Get_Current_Caps()->Support_Texture_Format( displayFormat )) { diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp index ff07662dcbc..ab74f32784a 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp @@ -3284,7 +3284,7 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4]) setupFlatWaterShader();// lorenzen sez use the alpha shader //If video card supports it and it's enabled, feather the water edge using destination alpha - if (DX8Wrapper::getBackBufferFormat() == WW3D_FORMAT_A8R8G8B8 && TheGlobalData->m_showSoftWaterEdge && TheWaterTransparency->m_transparentWaterDepth !=0) + if (Renderer::Get_Back_Buffer_Format() == WW3D_FORMAT_A8R8G8B8 && TheGlobalData->m_showSoftWaterEdge && TheWaterTransparency->m_transparentWaterDepth !=0) { DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND, D3DBLEND_DESTALPHA ); if (!TheWaterTransparency->m_additiveBlend) DX8Wrapper::Set_DX8_Render_State(D3DRS_DESTBLEND, D3DBLEND_INVDESTALPHA ); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp index d2c63d5f9cc..7305aaa7e4e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp @@ -60,6 +60,66 @@ void Renderer::Shutdown() Initialized = false; } +int Renderer::Get_Render_Device_Count() +{ + return DX8Wrapper::Get_Render_Device_Count(); +} + +int Renderer::Get_Render_Device() +{ + return DX8Wrapper::Get_Render_Device(); +} + +const char * Renderer::Get_Render_Device_Name(int device_index) +{ + return DX8Wrapper::Get_Render_Device_Name(device_index); +} + +void Renderer::Get_Device_Resolution(int & width, int & height, int & bits, bool & windowed) +{ + DX8Wrapper::Get_Device_Resolution(width, height, bits, windowed); +} + +void Renderer::Get_Render_Target_Resolution(int & width, int & height, int & bits, bool & windowed) +{ + DX8Wrapper::Get_Render_Target_Resolution(width, height, bits, windowed); +} + +int Renderer::Get_Device_Resolution_Width() +{ + return DX8Wrapper::Get_Device_Resolution_Width(); +} + +int Renderer::Get_Device_Resolution_Height() +{ + return DX8Wrapper::Get_Device_Resolution_Height(); +} + +bool Renderer::Is_Windowed() +{ + return DX8Wrapper::Is_Windowed(); +} + +int Renderer::Get_Texture_Bitdepth() +{ + return DX8Wrapper::Get_Texture_Bitdepth(); +} + +int Renderer::Get_Swap_Interval() +{ + return DX8Wrapper::Get_Swap_Interval(); +} + +bool Renderer::Has_Stencil() +{ + return DX8Wrapper::Has_Stencil(); +} + +WW3DFormat Renderer::Get_Back_Buffer_Format() +{ + return DX8Wrapper::getBackBufferFormat(); +} + void Renderer::Set_Gamma(float gamma, float bright, float contrast, bool calibrate, bool uselimit) { DX8Wrapper::Set_Gamma(gamma, bright, contrast, calibrate, uselimit); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h b/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h index 435e4845a73..af3269e15cd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/Renderer.h @@ -23,8 +23,10 @@ #pragma once +#include "WW3D2/ww3dformat.h" + // Forward declarations keep this header includable without pulling in the full -// WW3D2 header graph. All W3D types below are passed by pointer or reference. +// WW3D2 header graph. All W3D classes below are passed by pointer or reference. class LightEnvironmentClass; class Vector3; @@ -39,13 +41,8 @@ struct RenderViewport float max_z; }; -// A method appears here once a caller routes through it, not in anticipation of -// one. The set below is what current callers route through; the rest of the -// DX8Wrapper API stays reachable through DX8Wrapper's static methods until a -// caller migrates, at which point the method it needs moves here. -// -// Method names intentionally match the existing DX8Wrapper names so migrating a -// caller is a mechanical DX8Wrapper::X(...) -> Renderer::X(...) rewrite. +// The interface holds only the methods that callers route through. The rest of +// the DX8Wrapper API is called directly. class Renderer { @@ -54,6 +51,19 @@ class Renderer static bool Init(void * window, bool lite); static void Shutdown(); + static int Get_Render_Device_Count(); + static int Get_Render_Device(); + static const char * Get_Render_Device_Name(int device_index); + static void Get_Device_Resolution(int & width, int & height, int & bits, bool & windowed); + static void Get_Render_Target_Resolution(int & width, int & height, int & bits, bool & windowed); + static int Get_Device_Resolution_Width(); + static int Get_Device_Resolution_Height(); + static bool Is_Windowed(); + static int Get_Texture_Bitdepth(); + static int Get_Swap_Interval(); + static bool Has_Stencil(); + static WW3DFormat Get_Back_Buffer_Format(); + static void Set_Gamma(float gamma, float bright, float contrast, bool calibrate = true, bool uselimit = true); static void Begin_Scene(); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 746dbedc75c..b8c093fe61c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -703,6 +703,7 @@ class DX8Wrapper friend void DX8_Assert(); friend class WW3D; + friend class Renderer; friend class DX8IndexBufferClass; friend class DX8VertexBufferClass; }; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp index 49e174f82f8..da10d2a80cd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp @@ -503,7 +503,7 @@ void *WW3D::Get_Window() *=============================================================================================*/ bool WW3D::Is_Windowed() { - return DX8Wrapper::Is_Windowed(); + return Renderer::Is_Windowed(); } /*********************************************************************************************** @@ -547,7 +547,7 @@ WW3DErrorType WW3D::Toggle_Windowed () *=============================================================================================*/ int WW3D::Get_Render_Device() { - return DX8Wrapper::Get_Render_Device(); + return Renderer::Get_Render_Device(); } @@ -586,7 +586,7 @@ const RenderDeviceDescClass & WW3D::Get_Render_Device_Desc(int deviceidx) *=============================================================================================*/ int WW3D::Get_Render_Device_Count() { - return DX8Wrapper::Get_Render_Device_Count(); + return Renderer::Get_Render_Device_Count(); } @@ -605,7 +605,7 @@ int WW3D::Get_Render_Device_Count() *=============================================================================================*/ const char * WW3D::Get_Render_Device_Name(int device_index) { - return DX8Wrapper::Get_Render_Device_Name(device_index); + return Renderer::Get_Render_Device_Name(device_index); } @@ -648,7 +648,7 @@ WW3DErrorType WW3D::Set_Device_Resolution(int width,int height,int bits,int wind *=============================================================================================*/ void WW3D::Get_Render_Target_Resolution(int & set_w,int & set_h,int & set_bits,bool & set_windowed) { - DX8Wrapper::Get_Render_Target_Resolution(set_w,set_h,set_bits,set_windowed); + Renderer::Get_Render_Target_Resolution(set_w,set_h,set_bits,set_windowed); } @@ -667,7 +667,7 @@ void WW3D::Get_Render_Target_Resolution(int & set_w,int & set_h,int & set_bits,b *=============================================================================================*/ void WW3D::Get_Device_Resolution(int & set_w,int & set_h,int & set_bits,bool & set_windowed) { - DX8Wrapper::Get_Device_Resolution(set_w,set_h,set_bits,set_windowed); + Renderer::Get_Device_Resolution(set_w,set_h,set_bits,set_windowed); } @@ -1233,7 +1233,7 @@ void WW3D::Set_Ext_Swap_Interval(long swap) *=============================================================================================*/ long WW3D::Get_Ext_Swap_Interval() { - return DX8Wrapper::Get_Swap_Interval(); + return Renderer::Get_Swap_Interval(); } @@ -1290,12 +1290,12 @@ int WW3D::Get_Collision_Box_Display_Mask() void WW3D::Normalize_Coordinates(int x, int y, float &fx, float &fy) { // clip the coordinates back into the resolution of the screen - x = Bound(x, 0, DX8Wrapper::Get_Device_Resolution_Width()); - y = Bound(y, 0, DX8Wrapper::Get_Device_Resolution_Height()); + x = Bound(x, 0, Renderer::Get_Device_Resolution_Width()); + y = Bound(y, 0, Renderer::Get_Device_Resolution_Height()); // now that the coordinates are clipped convert them to their normalized values. - fx = (float)x / DX8Wrapper::Get_Device_Resolution_Width(); - fy = (float)y / DX8Wrapper::Get_Device_Resolution_Height(); + fx = (float)x / Renderer::Get_Device_Resolution_Width(); + fy = (float)y / Renderer::Get_Device_Resolution_Height(); } @@ -2025,7 +2025,7 @@ void WW3D::Set_Texture_Bitdepth(int bitdepth) int WW3D::Get_Texture_Bitdepth() { - return DX8Wrapper::Get_Texture_Bitdepth(); + return Renderer::Get_Texture_Bitdepth(); } void WW3D::Set_MSAA_Mode(MultiSampleModeEnum mode) diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp index e2ca0168767..fd54f1995f9 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp @@ -43,6 +43,7 @@ #include "WW3D2/camera.h" #include "WW3D2/light.h" #include "WW3D2/dx8wrapper.h" +#include "WW3D2/Renderer.h" #include "WW3D2/hlod.h" #include "WW3D2/mesh.h" #include "WW3D2/meshmdl.h" @@ -3850,7 +3851,7 @@ void W3DVolumetricShadowManager::reset() // ============================================================================ W3DVolumetricShadow* W3DVolumetricShadowManager::addShadow(RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo, Drawable *draw) { - if (!DX8Wrapper::Has_Stencil() || !robj || !TheGlobalData->m_useShadowVolumes) + if (!Renderer::Has_Stencil() || !robj || !TheGlobalData->m_useShadowVolumes) return nullptr; //right now we require a stencil buffer W3DShadowGeometry *sg=nullptr; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp index 13ff3b4b3e5..53de7a8bb57 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp @@ -859,7 +859,7 @@ void RTS3DScene::Flush(RenderInfoClass & rinfo) #ifdef USE_NON_STENCIL_OCCLUSION flushOccludedObjects(rinfo); #else - if (DX8Wrapper::Has_Stencil()) + if (Renderer::Has_Stencil()) flushOccludedObjectsIntoStencil(rinfo); #endif @@ -975,7 +975,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo) DX8Wrapper::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 && DX8Wrapper::Has_Stencil(); + TheWritableGlobalData->m_enableBehindBuildingMarkers = TheWritableGlobalData->m_enableBehindBuildingMarkers && Renderer::Has_Stencil(); if (Get_Extra_Pass_Polygon_Mode() == EXTRA_PASS_DISABLE) { @@ -1575,7 +1575,7 @@ void RTS3DScene::flushOccludedObjects(RenderInfoClass & rinfo) { const Int localPlayerIndex = rts::getObservedOrLocalPlayerIndex_Safe(); - if (DX8Wrapper::Has_Stencil()) //just in case we have shadows, disable them over occluded pixels. + if (Renderer::Has_Stencil()) //just in case we have shadows, disable them over occluded pixels. { //Set all stencil pixels of potentially occluded objects to 128. DX8Wrapper::Set_DX8_Render_State(D3DRS_STENCILENABLE, TRUE ); @@ -1614,7 +1614,7 @@ void RTS3DScene::flushOccludedObjects(RenderInfoClass & rinfo) //Now draw the normal models so they cover up the colored models on any pixels that //Normal models will clear stencil value from 128 back to 0 where the object pixels are //not occluded but will leave 128 in stencil where still occluded. - if (DX8Wrapper::Has_Stencil()) + if (Renderer::Has_Stencil()) DX8Wrapper::Set_DX8_Render_State(D3DRS_STENCILREF, 0 ); for (i=0; i