diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp index 4cbe7db3bad..b8f3e52ea8c 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/IRenderBackend.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 (WW3D::Get_Render_Backend()->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 (WW3D::Get_Render_Backend()->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..4c6ac103cec 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/IRenderBackend.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 (WW3D::Get_Render_Backend()->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..cff9c53c5cd 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/IRenderBackend.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 (WW3D::Get_Render_Backend()->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 b7d6a44a5b5..fcac1d9d5fd 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp @@ -86,6 +86,7 @@ static void drawFramerateBar(); #include "WWMath/wwmath.h" #include "WWLib/registry.h" #include "WW3D2/ww3d.h" +#include "WW3D2/IRenderBackend.h" #include "WW3D2/predlod.h" #include "WW3D2/part_emt.h" #include "WW3D2/part_ldr.h" @@ -549,7 +550,7 @@ void W3DDisplay::setGamma(Real gamma, Real bright, Real contrast, Bool calibrate if (m_windowed) return; //we don't allow gamma to change in window because it would affect desktop. - DX8Wrapper::Set_Gamma(gamma,bright,contrast,calibrate, false); + WW3D::Get_Render_Backend()->Set_Gamma(gamma,bright,contrast,calibrate, false); } /** Set resolution of display */ @@ -2936,7 +2937,7 @@ VideoBuffer* W3DDisplay::createVideoBuffer() // first try to use the native format - WW3DFormat displayFormat = DX8Wrapper::getBackBufferFormat(); + WW3DFormat displayFormat = WW3D::Get_Render_Backend()->Get_Back_Buffer_Format(); if ( DX8Wrapper::Get_Current_Caps()->Support_Texture_Format( displayFormat )) { diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp index bed86510ad0..9673e73d2d4 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp @@ -54,6 +54,7 @@ //----------------------------------------------------------------------------- #include "WW3D2/dx8wrapper.h" +#include "WW3D2/IRenderBackend.h" #include "WW3D2/assetmgr.h" #include "Lib/BaseType.h" #include "Common/file.h" @@ -2906,7 +2907,7 @@ void W3DShaderManager::startRenderToTexture() DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE); //disable writes to alpha } else //normal clear that overwrites everything. - DX8Wrapper::Clear(true, false, Vector3( 0.0f, 0.0f, 0.0f ), TheWaterTransparency->m_minWaterOpacity); + WW3D::Get_Render_Backend()->Clear(true, false, Vector3( 0.0f, 0.0f, 0.0f ), TheWaterTransparency->m_minWaterOpacity); } } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index d438761a744..531acf34b17 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -94,6 +94,7 @@ #include "WW3D2/light.h" #include "WW3D2/predlod.h" #include "WW3D2/ww3d.h" +#include "WW3D2/IRenderBackend.h" #include "W3DDevice/GameClient/CameraShakeSystem.h" @@ -1916,7 +1917,7 @@ void W3DView::draw() //The pass that rendered into a texture may have left the z-buffer in a weird state //so clear it before rendering normal scene. ///@todo: Don't clear z-buffer unless shader uses z-bias or anything else that would cause <= z to fail on normal render. - DX8Wrapper::Clear(false, true, Vector3(0.0f,0.0f,0.0f), TheWaterTransparency->m_minWaterOpacity); // Clear z but not color + WW3D::Get_Render_Backend()->Clear(false, true, Vector3(0.0f,0.0f,0.0f), TheWaterTransparency->m_minWaterOpacity); // Clear z but not color W3DDisplay::m_3DScene->setCustomPassMode(SCENE_PASS_DEFAULT); W3DDisplay::m_3DScene->doRender( m_3DCamera ); Coord2D deltaScroll; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp index b2375cb1269..cfbf09f880f 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp @@ -43,6 +43,7 @@ #include "WW3D2/camera.h" #include "WW3D2/scene.h" #include "WW3D2/dx8wrapper.h" +#include "WW3D2/IRenderBackend.h" #include "WW3D2/light.h" #include "d3dx8math.h" #include "WWLib/simplevec.h" @@ -1711,7 +1712,7 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo) rinfo.Camera.Apply(); //force an update of all the camera dependent parameters like frustum clip planes //clear the z-buffer to remove changes made by objects inside mirror - DX8Wrapper::Clear(false,true,Vector3(0.1f,0.1f,0.1f)); + WW3D::Get_Render_Backend()->Clear(false,true,Vector3(0.1f,0.1f,0.1f)); } #endif @@ -3283,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 (WW3D::Get_Render_Backend()->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 fac042dc906..50f3b06689b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp @@ -59,6 +59,66 @@ DX8Backend *DX8Backend::Create(void * window, bool lite) return new DX8Backend(lite); } +int DX8Backend::Get_Render_Device_Count() const +{ + return DX8Wrapper::Get_Render_Device_Count(); +} + +int DX8Backend::Get_Render_Device() const +{ + return DX8Wrapper::Get_Render_Device(); +} + +const char * DX8Backend::Get_Render_Device_Name(int device_index) const +{ + return DX8Wrapper::Get_Render_Device_Name(device_index); +} + +void DX8Backend::Get_Device_Resolution(int & width, int & height, int & bits, bool & windowed) const +{ + DX8Wrapper::Get_Device_Resolution(width, height, bits, windowed); +} + +void DX8Backend::Get_Render_Target_Resolution(int & width, int & height, int & bits, bool & windowed) const +{ + DX8Wrapper::Get_Render_Target_Resolution(width, height, bits, windowed); +} + +int DX8Backend::Get_Device_Resolution_Width() const +{ + return DX8Wrapper::Get_Device_Resolution_Width(); +} + +int DX8Backend::Get_Device_Resolution_Height() const +{ + return DX8Wrapper::Get_Device_Resolution_Height(); +} + +bool DX8Backend::Is_Windowed() const +{ + return DX8Wrapper::Is_Windowed(); +} + +int DX8Backend::Get_Texture_Bitdepth() const +{ + return DX8Wrapper::Get_Texture_Bitdepth(); +} + +int DX8Backend::Get_Swap_Interval() const +{ + return DX8Wrapper::Get_Swap_Interval(); +} + +bool DX8Backend::Has_Stencil() const +{ + return DX8Wrapper::Has_Stencil(); +} + +WW3DFormat DX8Backend::Get_Back_Buffer_Format() const +{ + return DX8Wrapper::getBackBufferFormat(); +} + void DX8Backend::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/Backend/DX8Backend.h b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.h index a5597c9edef..6eab3aa1a67 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.h @@ -31,6 +31,19 @@ class DX8Backend : public IRenderBackend virtual ~DX8Backend() override; + virtual int Get_Render_Device_Count() const override; + virtual int Get_Render_Device() const override; + virtual const char * Get_Render_Device_Name(int device_index) const override; + virtual void Get_Device_Resolution(int & width, int & height, int & bits, bool & windowed) const override; + virtual void Get_Render_Target_Resolution(int & width, int & height, int & bits, bool & windowed) const override; + virtual int Get_Device_Resolution_Width() const override; + virtual int Get_Device_Resolution_Height() const override; + virtual bool Is_Windowed() const override; + virtual int Get_Texture_Bitdepth() const override; + virtual int Get_Swap_Interval() const override; + virtual bool Has_Stencil() const override; + virtual WW3DFormat Get_Back_Buffer_Format() const override; + virtual void Set_Gamma(float gamma, float bright, float contrast, bool calibrate, bool uselimit) override; virtual void Begin_Scene() override; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h b/Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h index 28dd3b14ec8..3989829e8f8 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h @@ -22,8 +22,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; @@ -38,20 +40,27 @@ struct RenderBackendViewport 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(...) -> Get_Render_Backend()->X(...) -// rewrite. +// The interface holds only the methods that callers route through. The rest of +// the DX8Wrapper API is called directly. class IRenderBackend { public: virtual ~IRenderBackend() {} + virtual int Get_Render_Device_Count() const = 0; + virtual int Get_Render_Device() const = 0; + virtual const char * Get_Render_Device_Name(int device_index) const = 0; + virtual void Get_Device_Resolution(int & width, int & height, int & bits, bool & windowed) const = 0; + virtual void Get_Render_Target_Resolution(int & width, int & height, int & bits, bool & windowed) const = 0; + virtual int Get_Device_Resolution_Width() const = 0; + virtual int Get_Device_Resolution_Height() const = 0; + virtual bool Is_Windowed() const = 0; + virtual int Get_Texture_Bitdepth() const = 0; + virtual int Get_Swap_Interval() const = 0; + virtual bool Has_Stencil() const = 0; + virtual WW3DFormat Get_Back_Buffer_Format() const = 0; + virtual void Set_Gamma(float gamma, float bright, float contrast, bool calibrate = true, bool uselimit = true) = 0; virtual void Begin_Scene() = 0; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 746dbedc75c..ce99aa2b6a6 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 DX8Backend; 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 c43588d279d..52dd5850ae7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp @@ -512,7 +512,7 @@ void *WW3D::Get_Window() *=============================================================================================*/ bool WW3D::Is_Windowed() { - return DX8Wrapper::Is_Windowed(); + return Get_Render_Backend()->Is_Windowed(); } /*********************************************************************************************** @@ -556,7 +556,7 @@ WW3DErrorType WW3D::Toggle_Windowed () *=============================================================================================*/ int WW3D::Get_Render_Device() { - return DX8Wrapper::Get_Render_Device(); + return Get_Render_Backend()->Get_Render_Device(); } @@ -595,7 +595,7 @@ const RenderDeviceDescClass & WW3D::Get_Render_Device_Desc(int deviceidx) *=============================================================================================*/ int WW3D::Get_Render_Device_Count() { - return DX8Wrapper::Get_Render_Device_Count(); + return Get_Render_Backend()->Get_Render_Device_Count(); } @@ -614,7 +614,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 Get_Render_Backend()->Get_Render_Device_Name(device_index); } @@ -657,7 +657,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); + Get_Render_Backend()->Get_Render_Target_Resolution(set_w,set_h,set_bits,set_windowed); } @@ -676,7 +676,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); + Get_Render_Backend()->Get_Device_Resolution(set_w,set_h,set_bits,set_windowed); } @@ -1242,7 +1242,7 @@ void WW3D::Set_Ext_Swap_Interval(long swap) *=============================================================================================*/ long WW3D::Get_Ext_Swap_Interval() { - return DX8Wrapper::Get_Swap_Interval(); + return Get_Render_Backend()->Get_Swap_Interval(); } @@ -1299,12 +1299,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, Get_Render_Backend()->Get_Device_Resolution_Width()); + y = Bound(y, 0, Get_Render_Backend()->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 / Get_Render_Backend()->Get_Device_Resolution_Width(); + fy = (float)y / Get_Render_Backend()->Get_Device_Resolution_Height(); } @@ -2034,7 +2034,7 @@ void WW3D::Set_Texture_Bitdepth(int bitdepth) int WW3D::Get_Texture_Bitdepth() { - return DX8Wrapper::Get_Texture_Bitdepth(); + return Get_Render_Backend()->Get_Texture_Bitdepth(); } void WW3D::Set_MSAA_Mode(MultiSampleModeEnum mode) diff --git a/Core/Tools/W3DView/GammaDialog.cpp b/Core/Tools/W3DView/GammaDialog.cpp index 4b9467b11f9..87af72ba4cf 100644 --- a/Core/Tools/W3DView/GammaDialog.cpp +++ b/Core/Tools/W3DView/GammaDialog.cpp @@ -22,7 +22,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "GammaDialog.h" -#include "WW3D2/dx8wrapper.h" +#include "WW3D2/ww3d.h" #ifdef RTS_DEBUG #define new DEBUG_NEW @@ -94,7 +94,7 @@ void GammaDialogClass::OnOK() if (m_gamma<10) m_gamma=10; if (m_gamma>30) m_gamma=30; ::AfxGetApp()->WriteProfileInt("Config","Gamma",m_gamma); - DX8Wrapper::Set_Gamma(m_gamma/10.0f,0.0f,1.0f); + WW3D::Set_Gamma(m_gamma/10.0f,0.0f,1.0f); CDialog::OnOK(); } @@ -103,7 +103,7 @@ void GammaDialogClass::OnReleasedcaptureGammaSlider(NMHDR* pNMHDR, LRESULT* pRes { // TODO: Add your control notification handler code here m_gamma=m_gammaslider.GetPos(); - DX8Wrapper::Set_Gamma(m_gamma/10.0f,0.0f,1.0f); + WW3D::Set_Gamma(m_gamma/10.0f,0.0f,1.0f); CString string; string.Format("%3.2f",m_gamma/10.0f); SetDlgItemText(IDC_GAMMA_DISPLAY,string); diff --git a/Core/Tools/W3DView/MainFrm.cpp b/Core/Tools/W3DView/MainFrm.cpp index e42303f5ee4..34e72ced8f9 100644 --- a/Core/Tools/W3DView/MainFrm.cpp +++ b/Core/Tools/W3DView/MainFrm.cpp @@ -587,7 +587,7 @@ CMainFrame::OnCreateClient gamma=gamma/10.0f; if (gamma<1.0) gamma=1.0; if (gamma>3.0) gamma=3.0; - DX8Wrapper::Set_Gamma(gamma,0.0f,1.0f); + WW3D::Set_Gamma(gamma,0.0f,1.0f); } } } @@ -4206,9 +4206,9 @@ void CMainFrame::OnEnableGammaCorrection() gamma=gamma/10.0f; if (gamma<1.0) gamma=1.0; if (gamma>3.0) gamma=3.0; - DX8Wrapper::Set_Gamma(gamma,0.0f,1.0f); + WW3D::Set_Gamma(gamma,0.0f,1.0f); } else { - DX8Wrapper::Set_Gamma(1.0,0.0f,1.0f); + WW3D::Set_Gamma(1.0,0.0f,1.0f); } } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp index e2ca0168767..b8cd89722cb 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/IRenderBackend.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 (!WW3D::Get_Render_Backend()->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 aedda9bc0da..f21b80938a0 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp @@ -57,6 +57,7 @@ #include "WW3D2/dx8renderer.h" #include "WW3D2/sortingrenderer.h" #include "WW3D2/dx8wrapper.h" +#include "WW3D2/IRenderBackend.h" #include "WW3D2/light.h" #include "WW3D2/matpass.h" #include "WW3D2/shader.h" @@ -858,7 +859,7 @@ void RTS3DScene::Flush(RenderInfoClass & rinfo) #ifdef USE_NON_STENCIL_OCCLUSION flushOccludedObjects(rinfo); #else - if (DX8Wrapper::Has_Stencil()) + if (WW3D::Get_Render_Backend()->Has_Stencil()) flushOccludedObjectsIntoStencil(rinfo); #endif @@ -974,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 && WW3D::Get_Render_Backend()->Has_Stencil(); if (Get_Extra_Pass_Polygon_Mode() == EXTRA_PASS_DISABLE) { @@ -1015,7 +1016,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo) //a projected alpha texture which will later be used to determine where //wireframe should be visible. ///@todo: Clearing to black may not be needed if the scene already did the clear. - DX8Wrapper::Clear(true, false, Vector3(0.0f,0.0f,0.0f),1.0f); // Clear color but not z + WW3D::Get_Render_Backend()->Clear(true, false, Vector3(0.0f,0.0f,0.0f),1.0f); // Clear color but not z DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA); DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0); @@ -1075,7 +1076,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo) Customized_Render(rinfo); break; case EXTRA_PASS_CLEAR_LINE: - DX8Wrapper::Clear(true, false, Vector3(0.0f,0.0f,0.0f), 0.0f); // Clear color but not z + WW3D::Get_Render_Backend()->Clear(true, false, Vector3(0.0f,0.0f,0.0f), 0.0f); // Clear color but not z WW3D::Enable_Texturing(false); WW3D::Enable_Coloring(0xff008000); DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME); @@ -1574,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 (WW3D::Get_Render_Backend()->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 ); @@ -1613,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 (WW3D::Get_Render_Backend()->Has_Stencil()) DX8Wrapper::Set_DX8_Render_State(D3DRS_STENCILREF, 0 ); for (i=0; iSet_Viewport(vp); Matrix4x4 d3dprojection; Get_D3D_Projection_Matrix(&d3dprojection); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp index 085a938fe72..0a9e1ccead7 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp @@ -42,6 +42,7 @@ #include "render2d.h" #include "WWLib/mutex.h" #include "ww3d.h" +#include "IRenderBackend.h" #include "font3d.h" #include "WWMath/rect.h" #include "texture.h" @@ -617,14 +618,14 @@ void Render2DClass::Render() int width, height, bits; bool windowed; WW3D::Get_Device_Resolution( width, height, bits, windowed ); - D3DVIEWPORT8 vp = { 0 }; - vp.X = 0; - vp.Y = 0; - vp.Width = width; - vp.Height = height; - vp.MinZ = 0; - vp.MaxZ = 1; - DX8Wrapper::Set_Viewport(&vp); + RenderBackendViewport vp; + vp.x = 0; + vp.y = 0; + vp.width = width; + vp.height = height; + vp.min_z = 0; + vp.max_z = 1; + WW3D::Get_Render_Backend()->Set_Viewport(vp); DX8Wrapper::Set_Texture(0,Texture); VertexMaterialClass *vm=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp index f7b975da694..a42c81658be 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp @@ -65,6 +65,7 @@ #include "WWMath/plane.h" #include "camera.h" #include "ww3d.h" +#include "IRenderBackend.h" #include "rinfo.h" #include "WWLib/chunkio.h" #include "dx8renderer.h" @@ -233,7 +234,7 @@ void SceneClass::Render(RenderInfoClass & rinfo) Customized_Render(rinfo); break; case EXTRA_PASS_CLEAR_LINE: - DX8Wrapper::Clear(true, false, Vector3(0.0f,0.0f,0.0f)); // Clear color but not z + WW3D::Get_Render_Backend()->Clear(true, false, Vector3(0.0f,0.0f,0.0f)); // Clear color but not z WW3D::Enable_Texturing(false); DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME); DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 7);