Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 ))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
//-----------------------------------------------------------------------------

#include "WW3D2/dx8wrapper.h"
#include "WW3D2/IRenderBackend.h"
#include "WW3D2/assetmgr.h"
#include "Lib/BaseType.h"
#include "Common/file.h"
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 );
Expand Down
60 changes: 60 additions & 0 deletions Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 18 additions & 9 deletions Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ class DX8Wrapper

friend void DX8_Assert();
friend class WW3D;
friend class DX8Backend;
friend class DX8IndexBufferClass;
friend class DX8VertexBufferClass;
};
Expand Down
24 changes: 12 additions & 12 deletions Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ void *WW3D::Get_Window()
*=============================================================================================*/
bool WW3D::Is_Windowed()
{
return DX8Wrapper::Is_Windowed();
return Get_Render_Backend()->Is_Windowed();
}

/***********************************************************************************************
Expand Down Expand Up @@ -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();
}


Expand Down Expand Up @@ -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();
}


Expand All @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand All @@ -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);
}


Expand Down Expand Up @@ -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();
}


Expand Down Expand Up @@ -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();
}


Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading