From 6ee1c8e9ee7b04464dc609e71aa42a98788be7f2 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 4 Jan 2015 17:57:52 +0100 Subject: [PATCH] Make sure to disable stencil in UIContext::Begin. Add logic ops to thin3d for completeness. --- thin3d/thin3d.h | 22 ++++++++++++++++++++++ thin3d/thin3d_d3d9.cpp | 1 + thin3d/thin3d_gl.cpp | 28 +++++++++++++++++++++++++++- ui/ui_context.cpp | 1 + 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/thin3d/thin3d.h b/thin3d/thin3d.h index e6d1397b48..16492f710b 100644 --- a/thin3d/thin3d.h +++ b/thin3d/thin3d.h @@ -32,6 +32,26 @@ enum T3DComparison : int { ALWAYS, }; +// Had to prefix with LOGIC, too many clashes +enum T3DLogicOp : int { + LOGIC_CLEAR, + LOGIC_SET, + LOGIC_COPY, + LOGIC_COPY_INVERTED, + LOGIC_NOOP, + LOGIC_INVERT, + LOGIC_AND, + LOGIC_NAND, + LOGIC_OR, + LOGIC_NOR, + LOGIC_XOR, + LOGIC_EQUIV, + LOGIC_AND_REVERSE, + LOGIC_AND_INVERTED, + LOGIC_OR_REVERSE, + LOGIC_OR_INVERTED, +}; + enum T3DBlendFactor : int { ZERO, ONE, @@ -251,6 +271,8 @@ struct T3DBlendStateDesc { T3DBlendEquation eqAlpha; T3DBlendFactor srcAlpha; T3DBlendFactor dstAlpha; + bool logicEnabled; + T3DLogicOp logicOp; // int colorMask; }; diff --git a/thin3d/thin3d_d3d9.cpp b/thin3d/thin3d_d3d9.cpp index 753468194d..278fa4b490 100644 --- a/thin3d/thin3d_d3d9.cpp +++ b/thin3d/thin3d_d3d9.cpp @@ -507,6 +507,7 @@ Thin3DBlendState *Thin3DDX9Context::CreateBlendState(const T3DBlendStateDesc &de bs->eqAlpha = blendEqToD3D9[desc.eqAlpha]; bs->srcAlpha = blendFactorToD3D9[desc.srcAlpha]; bs->dstAlpha = blendFactorToD3D9[desc.dstAlpha]; + // Ignore logic ops, we don't support them in D3D9 return bs; } diff --git a/thin3d/thin3d_gl.cpp b/thin3d/thin3d_gl.cpp index 92e8b3c30a..f04935dec4 100644 --- a/thin3d/thin3d_gl.cpp +++ b/thin3d/thin3d_gl.cpp @@ -41,6 +41,25 @@ static const unsigned short blendFactorToGL[] = { GL_CONSTANT_COLOR, }; +static const unsigned short logicOpToGL[] = { + GL_CLEAR, + GL_SET, + GL_COPY, + GL_COPY_INVERTED, + GL_NOOP, + GL_INVERT, + GL_AND, + GL_NAND, + GL_OR, + GL_NOR, + GL_XOR, + GL_EQUIV, + GL_AND_REVERSE, + GL_AND_INVERTED, + GL_OR_REVERSE, + GL_OR_INVERTED, +}; + static const unsigned short primToGL[] = { GL_POINTS, GL_LINES, @@ -64,6 +83,8 @@ public: bool enabled; GLuint eqCol, eqAlpha; GLuint srcCol, srcAlpha, dstCol, dstAlpha; + bool logicEnabled; + GLuint logicOp; // int maskBits; // uint32_t fixedColor; @@ -75,7 +96,10 @@ public: // glstate.blendColor.set(fixedColor); #if !defined(USING_GLES2) - glstate.colorLogicOp.disable(); + glstate.colorLogicOp.set(logicEnabled); + if (logicEnabled) { + glstate.logicOp.set(logicOp); + } #endif // glstate.colorMask.set(maskBits & 1, (maskBits >> 1) & 1, (maskBits >> 2) & 1, (maskBits >> 3) & 1); @@ -510,6 +534,8 @@ Thin3DBlendState *Thin3DGLContext::CreateBlendState(const T3DBlendStateDesc &des bs->eqAlpha = blendEqToGL[desc.eqAlpha]; bs->srcAlpha = blendFactorToGL[desc.srcAlpha]; bs->dstAlpha = blendFactorToGL[desc.dstAlpha]; + bs->logicEnabled = desc.logicEnabled; + bs->logicOp = logicOpToGL[desc.logicOp]; return bs; } diff --git a/ui/ui_context.cpp b/ui/ui_context.cpp index 7dbf2e1381..5aa410c14c 100644 --- a/ui/ui_context.cpp +++ b/ui/ui_context.cpp @@ -41,6 +41,7 @@ void UIContext::Begin() { thin3d_->SetDepthStencilState(depth_); thin3d_->SetRenderState(T3DRenderState::CULL_MODE, T3DCullMode::NO_CULL); thin3d_->SetTexture(0, uitexture_); + thin3d_->SetScissorEnabled(false); UIBegin(uishader_); }