1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

OpenGLFrameBuffer: Use ScopeGuard to unbind framebuffer

This commit is contained in:
reuk 2025-07-03 15:56:45 +01:00
parent c2d52a5499
commit 1900dd4e4a
No known key found for this signature in database

View file

@ -119,6 +119,7 @@ public:
auto* transientState = std::get_if<TransientState> (&state);
transientState->bind();
const ScopeGuard unbinder { [transientState] { transientState->unbind(); }};
#if ! JUCE_ANDROID
if (! associatedContext->isCoreProfile())
@ -132,7 +133,6 @@ public:
associatedContext->copyTexture (area, area, area.getWidth(), area.getHeight(), false);
}
transientState->unbind();
return true;
}
@ -218,8 +218,8 @@ public:
if (transientState == nullptr)
return;
const ScopeGuard unbinder { [transientState] { transientState->unbind(); }};
OpenGLHelpers::clear (colour);
transientState->unbind();
}
void makeCurrentAndClear()
@ -240,11 +240,12 @@ public:
if (transientState == nullptr)
return false;
const ScopeGuard unbinder { [transientState] { transientState->unbind(); }};
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glReadPixels (area.getX(), area.getY(), area.getWidth(), area.getHeight(),
JUCE_RGBA_FORMAT, GL_UNSIGNED_BYTE, target);
transientState->unbind();
return true;
}
@ -324,6 +325,7 @@ private:
gl::glGenFramebuffers (1, &frameBufferID);
bind();
const ScopeGuard unbinder { [this] { unbind(); }};
{
const ScopedTextureBinding scopedTextureBinding;
@ -369,8 +371,6 @@ private:
if (wantsStencilBuffer)
gl::glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthOrStencilBuffer);
}
unbind();
}
~TransientState()