Browse Source

Disabled depth-test when overlaying 2D rendering on openGL 3D content

tags/2021-05-28
jules 9 years ago
parent
commit
b355af98a1
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp

+ 23
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -894,6 +894,27 @@ void OpenGLContext::setAssociatedObject (const char* name, ReferenceCountedObjec
void OpenGLContext::setImageCacheSize (size_t newSize) noexcept { imageCacheMaxSize = newSize; } void OpenGLContext::setImageCacheSize (size_t newSize) noexcept { imageCacheMaxSize = newSize; }
size_t OpenGLContext::getImageCacheSize() const noexcept { return imageCacheMaxSize; } 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<int>& targetClipArea, void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
const Rectangle<int>& anchorPosAndTextureSize, const Rectangle<int>& anchorPosAndTextureSize,
const int contextWidth, const int contextHeight, const int contextWidth, const int contextHeight,
@@ -906,6 +927,8 @@ void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_BLEND); glEnable (GL_BLEND);
DepthTestDisabler depthDisabler;
if (areShadersAvailable()) if (areShadersAvailable())
{ {
struct OverlayShaderProgram : public ReferenceCountedObject struct OverlayShaderProgram : public ReferenceCountedObject


Loading…
Cancel
Save