Browse Source

Save and restore blend state when using nanovg

pull/6/head
falkTX 8 years ago
parent
commit
d1ecc17a68
2 changed files with 16 additions and 1 deletions
  1. +15
    -0
      dgl/src/NanoVG.cpp
  2. +1
    -1
      dgl/src/nanovg/nanovg_gl.h

+ 15
- 0
dgl/src/NanoVG.cpp View File

@@ -212,9 +212,24 @@ void NanoVG::endFrame()
{
DISTRHO_SAFE_ASSERT_RETURN(fInFrame,);

// Save current blend state
GLboolean blendEnabled;
GLint blendSrc, blendDst;
glGetBooleanv(GL_BLEND, &blendEnabled);
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrc);
glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDst);

if (fContext != nullptr)
nvgEndFrame(fContext);

// Restore blend state
if (blendEnabled)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);

glBlendFunc(blendSrc, blendDst);

fInFrame = false;
}



+ 1
- 1
dgl/src/nanovg/nanovg_gl.h View File

@@ -1138,7 +1138,7 @@ static void glnvg__renderFlush(void* uptr)
glBindVertexArray(0);
#endif
glDisable(GL_CULL_FACE);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);
glnvg__bindTexture(gl, 0);
}


Loading…
Cancel
Save