Skip to content

Commit

Permalink
xrRender/R_Backend.h: implemented set_FillMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 22, 2020
1 parent 98c22ae commit a1e5812
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Layers/xrRender/R_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class ECORE_API CBackend
u32 stencil_pass;
u32 stencil_zfail;
u32 colorwrite_mask;
u32 fill_mode;
u32 cull_mode;
u32 z_enable;
u32 z_func;
Expand Down Expand Up @@ -354,6 +355,7 @@ class ECORE_API CBackend
D3DCOLORWRITEENABLE_ALPHA);
IC void set_CullMode(u32 _mode);
u32 get_CullMode() { return cull_mode; }
IC void set_FillMode(u32 _mode);
void set_ClipPlanes(u32 _enable, Fplane* _planes = nullptr, u32 count = 0);
void set_ClipPlanes(u32 _enable, Fmatrix* _xform = nullptr, u32 fmask = 0xff);
IC void set_Scissor(Irect* rect = nullptr);
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender/R_Backend_Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void CBackend::Invalidate()
stencil_pass = u32(-1);
stencil_zfail = u32(-1);
cull_mode = u32(-1);
fill_mode = u32(-1);
z_enable = u32(-1);
z_func = u32(-1);
alpha_ref = u32(-1);
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRenderDX10/CommonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef D3D10_TEXTURE_ADDRESS_MODE D3D_TEXTURE_ADDRESS_MODE;
typedef D3D10_COMPARISON_FUNC D3D_COMPARISON_FUNC;
typedef D3D10_STENCIL_OP D3D_STENCIL_OP;
typedef D3D10_CULL_MODE D3D_CULL_MODE;
typedef D3D10_FILL_MODE D3D_FILL_MODE;
typedef D3D10_FILTER D3D_FILTER;

typedef D3D10_SAMPLER_DESC D3D_SAMPLER_DESC;
Expand Down
12 changes: 12 additions & 0 deletions src/Layers/xrRenderDX10/StateManager/dx10StateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,18 @@ void dx10StateManager::SetCullMode(u32 Mode)
}
}

void dx10StateManager::SetFillMode(u32 Mode)
{
ValidateRDesc();

D3D_FILL_MODE CMode = dx10StateUtils::ConvertFillMode((D3DFILLMODE)Mode);
if (m_RDesc.FillMode != CMode)
{
m_bRSChanged = true;
m_RDesc.FillMode = CMode;
}
}

void dx10StateManager::SetMultisample(u32 Enable)
{
ValidateRDesc();
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRenderDX10/StateManager/dx10StateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class dx10StateManager
void SetDepthEnable(u32 Enable);
void SetColorWriteEnable(u32 WriteMask);
void SetCullMode(u32 Mode);
void SetFillMode(u32 Mode);
void SetMultisample(u32 Enable);
void SetSampleMask(u32 Mask);

Expand Down
5 changes: 5 additions & 0 deletions src/Layers/xrRenderDX10/dx10R_Backend_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ ICF void CBackend::set_CullMode(u32 _mode)
// )); }
}

ICF void CBackend::set_FillMode(u32 _mode)
{
StateManager.SetFillMode(_mode);
}

IC void CBackend::ApplyVertexLayout()
{
VERIFY(vs);
Expand Down
10 changes: 10 additions & 0 deletions src/Layers/xrRenderDX10/dx10StateUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

namespace dx10StateUtils
{
D3D_FILL_MODE ConvertFillMode(D3DFILLMODE Mode)
{
switch (Mode)
{
case D3DFILL_WIREFRAME: return D3D_FILL_SOLID;
case D3DFILL_SOLID: return D3D_FILL_WIREFRAME;
default: VERIFY(!"Unexpected fill mode!"); return D3D_FILL_SOLID;
}
}

D3D_CULL_MODE ConvertCullMode(D3DCULL Mode)
{
switch (Mode)
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRenderDX10/dx10StateUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace dx10StateUtils
{
D3D_FILL_MODE ConvertFillMode(D3DFILLMODE Mode);
D3D_CULL_MODE ConvertCullMode(D3DCULL Mode);
D3D_COMPARISON_FUNC ConvertCmpFunction(D3DCMPFUNC Func);
D3D_STENCIL_OP ConvertStencilOp(D3DSTENCILOP Op);
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRenderDX11/CommonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef D3D11_TEXTURE_ADDRESS_MODE D3D_TEXTURE_ADDRESS_MODE;
typedef D3D11_COMPARISON_FUNC D3D_COMPARISON_FUNC;
typedef D3D11_STENCIL_OP D3D_STENCIL_OP;
typedef D3D11_CULL_MODE D3D_CULL_MODE;
typedef D3D11_FILL_MODE D3D_FILL_MODE;
typedef D3D11_FILTER D3D_FILTER;

typedef D3D11_SAMPLER_DESC D3D_SAMPLER_DESC;
Expand Down
9 changes: 9 additions & 0 deletions src/Layers/xrRenderDX9/dx9R_Backend_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ ICF void CBackend::set_CullMode(u32 _mode)
}
}

ICF void CBackend::set_FillMode(u32 _mode)
{
if (fill_mode != _mode)
{
fill_mode = _mode;
CHK_DX(HW.pDevice->SetRenderState(D3DRS_FILLMODE, _mode));
}
}

ICF void CBackend::set_VS(ref_vs& _vs) { set_VS(_vs->sh, _vs->cName.c_str()); }
IC void CBackend::set_Constants(R_constant_table* C)
{
Expand Down
9 changes: 9 additions & 0 deletions src/Layers/xrRenderGL/glR_Backend_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ ICF void CBackend::set_CullMode(u32 _mode)
}
}

ICF void CBackend::set_FillMode(u32 _mode)
{
if (fill_mode != _mode)
{
fill_mode = _mode;
glPolygonMode(GL_FRONT_AND_BACK, glStateUtils::ConvertFillMode(_mode));
}
}

ICF void CBackend::set_VS(ref_vs& _vs)
{
set_VS(_vs->sh, _vs->cName.c_str());
Expand Down
16 changes: 16 additions & 0 deletions src/Layers/xrRenderGL/glStateUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@

namespace glStateUtils
{
GLenum ConvertFillMode(u32 Mode)
{
switch (Mode)
{
case D3DFILL_POINT:
return GL_POINT;
case D3DFILL_WIREFRAME:
return GL_LINE;
case D3DFILL_SOLID:
return GL_FILL;
default:
VERIFY(!"Unexpected fill mode!");
return GL_FILL;
}
}

GLenum ConvertCullMode(u32 Mode)
{
switch (Mode)
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRenderGL/glStateUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace glStateUtils
{
GLenum ConvertFillMode(u32 Mode);
GLenum ConvertCullMode(u32 Mode);
GLenum ConvertCmpFunction(u32 Func);
GLenum ConvertStencilOp(u32 Op);
Expand Down

0 comments on commit a1e5812

Please sign in to comment.