diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index f2c66ac630..90aeeb2c8c 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -478,6 +478,82 @@ void FGLRenderState::EnableClipDistance(int num, bool state) } } +void FGLRenderState::Clear(int targets) +{ + // This always clears to default values. + int gltarget = 0; + if (targets & CT_Depth) + { + gltarget |= GL_DEPTH_BUFFER_BIT; + glClearDepth(1); + } + if (targets & CT_Stencil) + { + gltarget |= GL_STENCIL_BUFFER_BIT; + glClearStencil(0); + } + if (targets & CT_Color) + { + gltarget |= GL_COLOR_BUFFER_BIT; + glClearColor(screen->mSceneClearColor[0], screen->mSceneClearColor[1], screen->mSceneClearColor[2], screen->mSceneClearColor[3]); + } + glClear(gltarget); +} + +void FGLRenderState::EnableStencil(bool on) +{ + if (on) + { + glEnable(GL_STENCIL_TEST); + } + else + { + glDisable(GL_STENCIL_TEST); + } +} + +void FGLRenderState::SetScissor(int x, int y, int w, int h) +{ + if (w > -1) + { + glEnable(GL_SCISSOR_TEST); + glScissor(x, y, w, h); + } + else + { + glDisable(GL_SCISSOR_TEST); + } +} + +void FGLRenderState::SetViewport(int x, int y, int w, int h) +{ + glViewport(x, y, w, h); +} + +void FGLRenderState::EnableDepthTest(bool on) +{ + if (on) + { + glEnable(GL_DEPTH_TEST); + } + else + { + glDisable(GL_DEPTH_TEST); + } +} + +void FGLRenderState::EnableMultisampling(bool on) +{ + if (on) + { + glEnable(GL_MULTISAMPLE); + } + else + { + glDisable(GL_MULTISAMPLE); + } +} + //========================================================================== // // diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 8d0f787184..ec2a23e5e1 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -153,6 +153,12 @@ public: void SetStencil(int offs, int op, int flags) override; void SetCulling(int mode) override; void EnableClipDistance(int num, bool state) override; + void Clear(int targets) override; + void EnableStencil(bool on) override; + void SetScissor(int x, int y, int w, int h) override; + void SetViewport(int x, int y, int w, int h) override; + void EnableDepthTest(bool on) override; + void EnableMultisampling(bool on) override; }; diff --git a/src/hwrenderer/scene/hw_renderstate.h b/src/hwrenderer/scene/hw_renderstate.h index 49d85188a6..bc06e859b2 100644 --- a/src/hwrenderer/scene/hw_renderstate.h +++ b/src/hwrenderer/scene/hw_renderstate.h @@ -12,7 +12,14 @@ struct FColormap; class IVertexBuffer; class IIndexBuffer; -enum EEffect +enum EClearTarget +{ + CT_Depth, + CT_Stencil, + CT_Color +}; + +enum ERenderEffect { EFF_NONE = -1, EFF_FOGBOUNDARY, @@ -440,6 +447,13 @@ public: virtual void SetStencil(int offs, int op, int flags) = 0; virtual void SetCulling(int mode) = 0; virtual void EnableClipDistance(int num, bool state) = 0; + virtual void Clear(int targets) = 0; + virtual void EnableStencil(bool on) = 0; + virtual void SetScissor(int x, int y, int w, int h) = 0; + virtual void SetViewport(int x, int y, int w, int h) = 0; + virtual void EnableDepthTest(bool on) = 0; + virtual void EnableMultisampling(bool on) = 0; + };