Skip to content
Open
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 @@ -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
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
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct RenderBackendViewport
// 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(...)
// caller is a mechanical DX8Wrapper::X(...) -> Get_Render_Backend().X(...)
// rewrite.

class IRenderBackend
Expand Down
20 changes: 10 additions & 10 deletions Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,12 @@ WW3DErrorType WW3D::Begin_Render(bool clear,bool clearz,const Vector3 & color, f
vp.height = height;
vp.min_z = 0.0f;
vp.max_z = 1.0f;
Get_Render_Backend()->Set_Viewport(vp);
Get_Render_Backend()->Clear(clear, clearz, color, dest_alpha);
Get_Render_Backend().Set_Viewport(vp);
Get_Render_Backend().Clear(clear, clearz, color, dest_alpha);
}

// Notify D3D that we are beginning to render the frame
Get_Render_Backend()->Begin_Scene();
Get_Render_Backend().Begin_Scene();

return WW3D_ERROR_OK;
}
Expand Down Expand Up @@ -968,7 +968,7 @@ WW3DErrorType WW3D::Render(SceneClass * scene,CameraClass * cam,bool clear,bool

// Clear the viewport
if (clear || clearz) {
Get_Render_Backend()->Clear(clear, clearz, color);
Get_Render_Backend().Clear(clear, clearz, color);
}

// set the rendering mode
Expand All @@ -986,7 +986,7 @@ WW3DErrorType WW3D::Render(SceneClass * scene,CameraClass * cam,bool clear,bool

// Set the global ambient light value here. If the scene is using the LightEnvironment system
// this setting will get overridden.
Get_Render_Backend()->Set_Ambient(scene->Get_Ambient_Light());
Get_Render_Backend().Set_Ambient(scene->Get_Ambient_Light());

// render the scene

Expand Down Expand Up @@ -1038,7 +1038,7 @@ WW3DErrorType WW3D::Render(

// Install the lighting environment if one is supplied
if (rinfo.light_environment != nullptr) {
Get_Render_Backend()->Set_Light_Environment(rinfo.light_environment);
Get_Render_Backend().Set_Light_Environment(rinfo.light_environment);
}

// Render the object
Expand Down Expand Up @@ -1114,7 +1114,7 @@ WW3DErrorType WW3D::End_Render(bool flip_frame)

{
WWPROFILE("IRenderBackend::End_Scene");
Get_Render_Backend()->End_Scene(flip_frame);
Get_Render_Backend().End_Scene(flip_frame);
}

FrameCount++;
Expand All @@ -1133,7 +1133,7 @@ WW3DErrorType WW3D::End_Render(bool flip_frame)
// (gth) I've found some cases where its not safe to rely on our "shadow" copy (of
// matrices for example) across multiple frames. So even though this is slightly
// less "optimal", lets just reset the caches each frame.
Get_Render_Backend()->Invalidate_Cached_Render_States();
Get_Render_Backend().Invalidate_Cached_Render_States();

return WW3D_ERROR_OK;
}
Expand All @@ -1153,7 +1153,7 @@ WW3DErrorType WW3D::End_Render(bool flip_frame)
*=============================================================================================*/
void WW3D::Flip_To_Primary()
{
Get_Render_Backend()->Flip_To_Primary();
Get_Render_Backend().Flip_To_Primary();
}


Expand Down Expand Up @@ -2123,5 +2123,5 @@ void WW3D::Reset_Current_Static_Sort_Lists_To_Default()

void WW3D::Set_Gamma(float gamma,float bright,float contrast,bool calibrate)
{
Get_Render_Backend()->Set_Gamma(gamma,bright,contrast,calibrate);
Get_Render_Backend().Set_Gamma(gamma,bright,contrast,calibrate);
}
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/ww3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class WW3D

// The active rendering backend.
// Created in Init and destroyed in Shutdown, so it is never null in between.
static IRenderBackend * Get_Render_Backend() { return RenderBackend; }
static IRenderBackend & Get_Render_Backend() { return *RenderBackend; }

static int Get_Render_Device_Count();
static const char * Get_Render_Device_Name(int device_index);
Expand Down
6 changes: 3 additions & 3 deletions Core/Tools/W3DView/GammaDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Core/Tools/W3DView/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}

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

Expand Down Expand Up @@ -1027,7 +1028,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);
Expand Down
17 changes: 9 additions & 8 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

#include "camera.h"
#include "ww3d.h"
#include "IRenderBackend.h"
#include "WWMath/matrix4.h"
#include "dx8wrapper.h"

Expand Down Expand Up @@ -738,14 +739,14 @@ void CameraClass::Apply()
bool windowed;
WW3D::Get_Render_Target_Resolution(width,height,bits,windowed);

D3DVIEWPORT8 vp;
vp.X = (DWORD)(Viewport.Min.X * (float)width);
vp.Y = (DWORD)(Viewport.Min.Y * (float)height);
vp.Width = (DWORD)((Viewport.Max.X - Viewport.Min.X) * (float)width);
vp.Height = (DWORD)((Viewport.Max.Y - Viewport.Min.Y) * (float)height);
vp.MinZ = ZBufferMin;
vp.MaxZ = ZBufferMax;
DX8Wrapper::Set_Viewport(&vp);
RenderBackendViewport vp;
vp.x = (unsigned int)(Viewport.Min.X * (float)width);
vp.y = (unsigned int)(Viewport.Min.Y * (float)height);
vp.width = (unsigned int)((Viewport.Max.X - Viewport.Min.X) * (float)width);
vp.height = (unsigned int)((Viewport.Max.Y - Viewport.Min.Y) * (float)height);
vp.min_z = ZBufferMin;
vp.max_z = ZBufferMax;
WW3D::Get_Render_Backend().Set_Viewport(vp);

Matrix4x4 d3dprojection;
Get_D3D_Projection_Matrix(&d3dprojection);
Expand Down
17 changes: 9 additions & 8 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "render2d.h"
#include "WWLib/mutex.h"
#include "ww3d.h"
#include "IRenderBackend.h"
#include "font3d.h"
#include "WWMath/rect.h"
#include "texture.h"
Expand Down Expand Up @@ -541,14 +542,14 @@ void Render2DClass::Render()
//
// Configure the viewport for entire screen
//
D3DVIEWPORT8 vp = { 0 };
vp.X = (DWORD)ScreenResolution.Left;
vp.Y = (DWORD)ScreenResolution.Top;
vp.Width = (DWORD)ScreenResolution.Width ();
vp.Height = (DWORD)ScreenResolution.Height ();
vp.MinZ = 0;
vp.MaxZ = 1;
DX8Wrapper::Set_Viewport(&vp);
RenderBackendViewport vp;
vp.x = (unsigned int)ScreenResolution.Left;
vp.y = (unsigned int)ScreenResolution.Top;
vp.width = (unsigned int)ScreenResolution.Width ();
vp.height = (unsigned int)ScreenResolution.Height ();
vp.min_z = 0;
vp.max_z = 1;
WW3D::Get_Render_Backend().Set_Viewport(vp);


DX8Wrapper::Set_Texture(0,Texture);
Expand Down
3 changes: 2 additions & 1 deletion Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "WWMath/plane.h"
#include "camera.h"
#include "ww3d.h"
#include "IRenderBackend.h"
#include "rinfo.h"
#include "WWLib/chunkio.h"
#include "dx8renderer.h"
Expand Down Expand Up @@ -226,7 +227,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
17 changes: 9 additions & 8 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

#include "camera.h"
#include "ww3d.h"
#include "IRenderBackend.h"
#include "WWMath/matrix4.h"
#include "dx8wrapper.h"

Expand Down Expand Up @@ -738,14 +739,14 @@ void CameraClass::Apply()
bool windowed;
WW3D::Get_Render_Target_Resolution(width,height,bits,windowed);

D3DVIEWPORT8 vp;
vp.X = (DWORD)(Viewport.Min.X * (float)width);
vp.Y = (DWORD)(Viewport.Min.Y * (float)height);
vp.Width = (DWORD)((Viewport.Max.X - Viewport.Min.X) * (float)width);
vp.Height = (DWORD)((Viewport.Max.Y - Viewport.Min.Y) * (float)height);
vp.MinZ = ZBufferMin;
vp.MaxZ = ZBufferMax;
DX8Wrapper::Set_Viewport(&vp);
RenderBackendViewport vp;
vp.x = (unsigned int)(Viewport.Min.X * (float)width);
vp.y = (unsigned int)(Viewport.Min.Y * (float)height);
vp.width = (unsigned int)((Viewport.Max.X - Viewport.Min.X) * (float)width);
vp.height = (unsigned int)((Viewport.Max.Y - Viewport.Min.Y) * (float)height);
vp.min_z = ZBufferMin;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is maybe a Nit question. But does this belong there?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a one-to-one swap of the old D3DVIEWPORT8 fill. Do you mean the struct should have a constructor, or that the viewport setup should live somewhere other than the camera? Or something else?

vp.max_z = ZBufferMax;
WW3D::Get_Render_Backend().Set_Viewport(vp);

Matrix4x4 d3dprojection;
Get_D3D_Projection_Matrix(&d3dprojection);
Expand Down
Loading
Loading