Refactored or removed some of the unused CDevice features

dev
Tomasz Kapuściński 2022-01-24 22:29:39 +01:00
parent 39b6621463
commit 2ff722eee6
5 changed files with 6 additions and 41 deletions

View File

@ -163,7 +163,6 @@ enum RenderState
RENDER_STATE_DEPTH_WRITE,
RENDER_STATE_ALPHA_TEST,
RENDER_STATE_CULLING,
RENDER_STATE_DEPTH_BIAS,
RENDER_STATE_SHADOW_MAPPING,
};
@ -510,7 +509,6 @@ public:
int first[], int count[], int drawCount) = 0;
virtual CVertexBuffer* CreateVertexBuffer(PrimitiveType primitiveType, const Vertex3D* vertices, int vertexCount) = 0;
virtual void DrawVertexBuffer(CVertexBuffer*) = 0;
virtual void DestroyVertexBuffer(CVertexBuffer*) = 0;
//! Changes rendering viewport
@ -522,12 +520,6 @@ public:
//! Sets the color mask
virtual void SetColorMask(bool red, bool green, bool blue, bool alpha) = 0;
//! Sets the function of depth test
virtual void SetDepthTestFunc(CompFunc func) = 0;
//! Sets the depth bias (constant value added to Z-coords)
virtual void SetDepthBias(float factor, float units) = 0;
//! Sets the alpha test function and reference value
virtual void SetAlphaTestFunc(CompFunc func, float refValue) = 0;

View File

@ -4049,8 +4049,6 @@ void CEngine::RenderShadowMap()
m_device->SetRenderState(RENDER_STATE_CULLING, false);
m_device->SetRenderState(RENDER_STATE_ALPHA_TEST, true);
m_device->SetAlphaTestFunc(COMP_FUNC_GREATER, 0.5f);
m_device->SetRenderState(RENDER_STATE_DEPTH_BIAS, true);
m_device->SetDepthBias(2.0f, 8.0f);
m_device->SetViewport(0, 0, m_shadowMap.size.x, m_shadowMap.size.y);
auto renderer = m_device->GetShadowRenderer();
@ -4170,8 +4168,6 @@ void CEngine::RenderShadowMap()
renderer->End();
m_device->SetRenderState(RENDER_STATE_DEPTH_BIAS, false);
m_device->SetDepthBias(0.0f, 0.0f);
m_device->SetRenderState(RENDER_STATE_ALPHA_TEST, false);
m_device->SetRenderState(RENDER_STATE_CULLING, false);
m_device->SetCullMode(CULL_CW);

View File

@ -1218,19 +1218,6 @@ CVertexBuffer* CGL33Device::CreateVertexBuffer(PrimitiveType primitiveType, cons
return buffer;
}
void CGL33Device::DrawVertexBuffer(CVertexBuffer* buffer)
{
if (m_updateLights) UpdateLights();
if (m_buffers.count(buffer) == 0) return;
auto b = dynamic_cast<CGL33VertexBuffer*>(buffer);
BindVAO(b->GetVAO());
GLenum type = TranslateGfxPrimitive(b->GetType());
glDrawArrays(type, 0, b->Size());
}
void CGL33Device::DestroyVertexBuffer(CVertexBuffer* buffer)
{
if (m_buffers.count(buffer) == 0) return;
@ -1288,7 +1275,6 @@ void CGL33Device::SetRenderState(RenderState state, bool enabled)
case RENDER_STATE_BLENDING: flag = GL_BLEND; break;
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
case RENDER_STATE_DEPTH_BIAS: flag = GL_POLYGON_OFFSET_FILL; break;
default: assert(false); break;
}
@ -1303,16 +1289,6 @@ void CGL33Device::SetColorMask(bool red, bool green, bool blue, bool alpha)
glColorMask(red, green, blue, alpha);
}
void CGL33Device::SetDepthTestFunc(CompFunc func)
{
glDepthFunc(TranslateGfxCompFunc(func));
}
void CGL33Device::SetDepthBias(float factor, float units)
{
glPolygonOffset(factor, units);
}
void CGL33Device::SetAlphaTestFunc(CompFunc func, float refValue)
{
glUniform1f(m_uniforms.alphaReference, refValue);

View File

@ -161,7 +161,6 @@ public:
int first[], int count[], int drawCount) override;
CVertexBuffer* CreateVertexBuffer(PrimitiveType primitiveType, const Vertex3D* vertices, int vertexCount) override;
void DrawVertexBuffer(CVertexBuffer*) override;
void DestroyVertexBuffer(CVertexBuffer*) override;
void SetViewport(int x, int y, int width, int height) override;
@ -170,10 +169,6 @@ public:
void SetColorMask(bool red, bool green, bool blue, bool alpha) override;
void SetDepthTestFunc(CompFunc func) override;
void SetDepthBias(float factor, float units) override;
void SetAlphaTestFunc(CompFunc func, float refValue) override;
void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) override;

View File

@ -547,6 +547,9 @@ void CGL33ShadowRenderer::Begin()
glUseProgram(m_program);
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(2.0f, 8.0f);
}
void CGL33ShadowRenderer::End()
@ -554,6 +557,9 @@ void CGL33ShadowRenderer::End()
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.0f, 0.0f);
m_device->Restore();
}