diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2018-08-15 15:53:42 +0300 |
---|---|---|
committer | Roman Kuznetsov <r.kuznetsow@gmail.com> | 2018-08-17 13:11:53 +0300 |
commit | 5ab189afac15e9e97aef702e69e0d883bc8532b9 (patch) | |
tree | a6f705150dff1cfa2e63616c8a77f03bafe69ce6 /drape/oglcontext.cpp | |
parent | d4673530fedab33c81e0a5453c43001a2b4ac983 (diff) |
Framebuffer and render state refactoring.
Diffstat (limited to 'drape/oglcontext.cpp')
-rw-r--r-- | drape/oglcontext.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/drape/oglcontext.cpp b/drape/oglcontext.cpp index d8ac0a62b5..7543b0fbeb 100644 --- a/drape/oglcontext.cpp +++ b/drape/oglcontext.cpp @@ -3,6 +3,52 @@ namespace dp { +namespace +{ +glConst DecodeTestFunction(TestFunction depthFunction) +{ + switch (depthFunction) + { + case TestFunction::Never: return gl_const::GLNever; + case TestFunction::Less: return gl_const::GLLess; + case TestFunction::Equal: return gl_const::GLEqual; + case TestFunction::LessOrEqual: return gl_const::GLLessOrEqual; + case TestFunction::Greater: return gl_const::GLGreat; + case TestFunction::NotEqual: return gl_const::GLNotEqual; + case TestFunction::GreaterOrEqual: return gl_const::GLGreatOrEqual; + case TestFunction::Always: return gl_const::GLAlways; + } + ASSERT(false, ()); +} + +glConst DecodeStencilFace(StencilFace stencilFace) +{ + switch (stencilFace) + { + case StencilFace::Front: return gl_const::GLFront; + case StencilFace::Back: return gl_const::GLBack; + case StencilFace::FrontAndBack: return gl_const::GLFrontAndBack; + } + ASSERT(false, ()); +} + +glConst DecodeStencilAction(StencilAction stencilAction) +{ + switch (stencilAction) + { + case StencilAction::Keep: return gl_const::GLKeep; + case StencilAction::Zero: return gl_const::GLZero; + case StencilAction::Replace: return gl_const::GLReplace; + case StencilAction::Incr: return gl_const::GLIncr; + case StencilAction::IncrWrap: return gl_const::GLIncrWrap; + case StencilAction::Decr: return gl_const::GLDecr; + case StencilAction::DecrWrap: return gl_const::GLDecrWrap; + case StencilAction::Invert: return gl_const::GLInvert; + } + ASSERT(false, ()); +} +} // namespace + void OGLContext::Init(ApiVersion apiVersion) { GLFunctions::Init(apiVersion); @@ -41,4 +87,39 @@ void OGLContext::Flush() { GLFunctions::glFlush(); } + +void OGLContext::SetDepthTestEnabled(bool enabled) +{ + if (enabled) + GLFunctions::glEnable(gl_const::GLDepthTest); + else + GLFunctions::glDisable(gl_const::GLDepthTest); +} + +void OGLContext::SetDepthTestFunction(TestFunction depthFunction) +{ + GLFunctions::glDepthFunc(DecodeTestFunction(depthFunction)); +}; + +void OGLContext::SetStencilTestEnabled(bool enabled) +{ + if (enabled) + GLFunctions::glEnable(gl_const::GLStencilTest); + else + GLFunctions::glDisable(gl_const::GLStencilTest); +} + +void OGLContext::SetStencilFunction(StencilFace face, TestFunction stencilFunction) +{ + GLFunctions::glStencilFuncSeparate(DecodeStencilFace(face), DecodeTestFunction(stencilFunction), 1, 1); +} + +void OGLContext::SetStencilActions(StencilFace face, StencilAction stencilFailAction, StencilAction depthFailAction, + StencilAction passAction) +{ + GLFunctions::glStencilOpSeparate(DecodeStencilFace(face), + DecodeStencilAction(stencilFailAction), + DecodeStencilAction(depthFailAction), + DecodeStencilAction(passAction)); +} } // namespace dp |