1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
JUCE/modules/juce_opengl/opengl
reuk 5eba9a6434
OpenGL: Clear bound texture after rendering transparency layer
A change introduced in 00836d1e94 meant
that GL renderers could sometimes assert in
StateHelpers::ActiveTextures::bindTexture() when ending a transparency
layer.

Specifically, the issue was provoked by adding the ScopedTextureBinding
in the constructor of OpenGLFrameBuffer. This reset the bound texture
after creating a new transparency layer.

I think the previous implementation worked by accident, not by design.
It so happens that when rendering multiple transparency layers within
the same frame (i.e. calling begin/end several times in that order,
*not* nesting the calls), the same texture ID will generally get reused.

From the graphics context's (GC's) perspective, we create a texture with
ID "2", then call bindTexture() to bind it, and the GC remembers that
this ID is bound. We draw the frame, and the texture gets destroyed. The
call to glDeleteTextures() will cause the default texture, "0", to be
bound if the texture being destroyed is bound at the point of
destruction. So, after the texture is destroyed, the GC's stored binding
no longer reflects reality, since texture "0" is now bound.

The next time we create a texture, that texture also gets created with
ID "2". Previously, we would leave this texture bound after
construction, but now we re-bind the previously-bound texture, "0". This
causes the assertion in bindTexture() to fire when we next attempt to
bind texture "2", since the actual bound texture is "0".

The solution added in this patch will bind texture "0" when the
transparency layer image is destroyed, in order to keep the GC's view of
the GL context consistent with the real state.
2025-08-14 14:13:09 +01:00
..
juce_gl.cpp Update licensing information 2024-04-16 11:39:35 +01:00
juce_gl.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_gles2.cpp Update licensing information 2024-04-16 11:39:35 +01:00
juce_gles2.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_khrplatform.h OpenGL: Update compatibility headers 2024-01-16 15:34:10 +00:00
juce_OpenGLContext.cpp OpenGLContext (Android): Avoid potentially enqueuing work after context has already stopped 2025-07-10 14:59:18 +01:00
juce_OpenGLContext.h Docs: Replace doxygen preprocessor conditionals with @cond and @endconds 2025-07-21 18:11:43 +02:00
juce_OpenGLFrameBuffer.cpp OpenGLFrameBuffer: Add a row order parameter for reading and writing pixels 2025-07-10 16:16:12 +01:00
juce_OpenGLFrameBuffer.h OpenGLFrameBuffer: Add a row order parameter for reading and writing pixels 2025-07-10 16:16:12 +01:00
juce_OpenGLGraphicsContext.cpp OpenGL: Clear bound texture after rendering transparency layer 2025-08-14 14:13:09 +01:00
juce_OpenGLGraphicsContext.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLHelpers.cpp Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLHelpers.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLImage.cpp OpenGLFrameBuffer: Add a row order parameter for reading and writing pixels 2025-07-10 16:16:12 +01:00
juce_OpenGLImage.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLPixelFormat.cpp Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLPixelFormat.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLRenderer.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLShaderProgram.cpp Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLShaderProgram.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_OpenGLTexture.cpp OpenGLTexture: Respect pixelStride when loading Image to texture 2024-12-13 14:42:26 +00:00
juce_OpenGLTexture.h Update licensing information 2024-04-16 11:39:35 +01:00
juce_wgl.h Update licensing information 2024-04-16 11:39:35 +01:00