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/Renderer.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 (Renderer::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 (Renderer::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/Renderer.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 (Renderer::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/Renderer.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 (Renderer::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 @@ -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 ))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
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 @@ -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);
Expand Down
26 changes: 18 additions & 8 deletions Core/Libraries/Source/WWVegas/WW3D2/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand All @@ -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();
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 Renderer;
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 @@ -503,7 +503,7 @@ void *WW3D::Get_Window()
*=============================================================================================*/
bool WW3D::Is_Windowed()
{
return DX8Wrapper::Is_Windowed();
return Renderer::Is_Windowed();
}

/***********************************************************************************************
Expand Down Expand Up @@ -547,7 +547,7 @@ WW3DErrorType WW3D::Toggle_Windowed ()
*=============================================================================================*/
int WW3D::Get_Render_Device()
{
return DX8Wrapper::Get_Render_Device();
return Renderer::Get_Render_Device();
}


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


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


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


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


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


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


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

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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<m_occludedObjectsCount; i++)
Expand Down
Loading