diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 1f73a25d24..12aaec37cb 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -894,6 +894,27 @@ void OpenGLContext::setAssociatedObject (const char* name, ReferenceCountedObjec void OpenGLContext::setImageCacheSize (size_t newSize) noexcept { imageCacheMaxSize = newSize; } size_t OpenGLContext::getImageCacheSize() const noexcept { return imageCacheMaxSize; } +//============================================================================== +struct DepthTestDisabler +{ + DepthTestDisabler() noexcept + { + glGetBooleanv (GL_DEPTH_TEST, &wasEnabled); + + if (wasEnabled) + glDisable (GL_DEPTH_TEST); + } + + ~DepthTestDisabler() noexcept + { + if (wasEnabled) + glEnable (GL_DEPTH_TEST); + } + + GLboolean wasEnabled; +}; + +//============================================================================== void OpenGLContext::copyTexture (const Rectangle& targetClipArea, const Rectangle& anchorPosAndTextureSize, const int contextWidth, const int contextHeight, @@ -906,6 +927,8 @@ void OpenGLContext::copyTexture (const Rectangle& targetClipArea, glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_BLEND); + DepthTestDisabler depthDisabler; + if (areShadersAvailable()) { struct OverlayShaderProgram : public ReferenceCountedObject