Browse Source

Added method OpenGLContext::deactivateCurrentContext().

tags/2021-05-28
jules 13 years ago
parent
commit
bd0741f9a9
7 changed files with 26 additions and 3 deletions
  1. +1
    -0
      modules/juce_opengl/native/juce_OpenGL_android.h
  2. +6
    -1
      modules/juce_opengl/native/juce_OpenGL_ios.h
  3. +6
    -1
      modules/juce_opengl/native/juce_OpenGL_linux.h
  4. +5
    -0
      modules/juce_opengl/native/juce_OpenGL_osx.h
  5. +2
    -1
      modules/juce_opengl/native/juce_OpenGL_win32.h
  6. +1
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  7. +5
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.h

+ 1
- 0
modules/juce_opengl/native/juce_OpenGL_android.h View File

@@ -68,6 +68,7 @@ public:
bool makeActive() const noexcept { return isInsideGLCallback; }
bool isActive() const noexcept { return isInsideGLCallback; }
static void deactivateCurrentContext() {}
void swapBuffers() const noexcept {}
bool setSwapInterval (const int) { return false; }


+ 6
- 1
modules/juce_opengl/native/juce_OpenGL_ios.h View File

@@ -81,7 +81,7 @@ public:
// so causes myserious timing-related failures.
[EAGLContext setCurrentContext: context];
createGLBuffers();
[EAGLContext setCurrentContext: nil];
deactivateCurrentContext();
}
~NativeContext()
@@ -119,6 +119,11 @@ public:
return [EAGLContext currentContext] == context;
}
static void deactivateCurrentContext()
{
[EAGLContext setCurrentContext: nil];
}
void swapBuffers()
{
glBindRenderbuffer (GL_RENDERBUFFER, colorBufferHandle);


+ 6
- 1
modules/juce_opengl/native/juce_OpenGL_linux.h View File

@@ -114,7 +114,7 @@ public:
void shutdownOnRenderThread()
{
glXMakeCurrent (display, None, 0);
deactivateCurrentContext();
glXDestroyContext (display, renderContext);
renderContext = nullptr;
}
@@ -130,6 +130,11 @@ public:
return glXGetCurrentContext() == renderContext && renderContext != 0;
}
static void deactivateCurrentContext()
{
glXMakeCurrent (display, None, 0);
}
void swapBuffers()
{
glXSwapBuffers (display, embeddedWindow);


+ 5
- 0
modules/juce_opengl/native/juce_OpenGL_osx.h View File

@@ -185,6 +185,11 @@ public:
return [NSOpenGLContext currentContext] == renderContext;
}
static void deactivateCurrentContext()
{
[NSOpenGLContext clearCurrentContext];
}
struct Locker
{
Locker (NativeContext& nc) : cglContext ((CGLContextObj) [nc.renderContext CGLContextObj])


+ 2
- 1
modules/juce_opengl/native/juce_OpenGL_win32.h View File

@@ -50,7 +50,7 @@ public:
initialiseGLExtensions();
const int wglFormat = wglChoosePixelFormatExtension (pixelFormat);
wglMakeCurrent (0, 0);
deactivateCurrentContext();
if (wglFormat != pixFormat && wglFormat != 0)
{
@@ -84,6 +84,7 @@ public:
void initialiseOnRenderThread() {}
void shutdownOnRenderThread() {}
static void deactivateCurrentContext() { wglMakeCurrent (0, 0); }
bool makeActive() const noexcept { return wglMakeCurrent (dc, renderContext) != FALSE; }
bool isActive() const noexcept { return wglGetCurrentContext() == renderContext; }
void swapBuffers() const noexcept { SwapBuffers (dc); }


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

@@ -545,6 +545,7 @@ OpenGLContext* OpenGLContext::getCurrentContext()
bool OpenGLContext::makeActive() const noexcept { return nativeContext != nullptr && nativeContext->makeActive(); }
bool OpenGLContext::isActive() const noexcept { return nativeContext != nullptr && nativeContext->isActive(); }
void OpenGLContext::deactivateCurrentContext() { NativeContext::deactivateCurrentContext(); }
void OpenGLContext::triggerRepaint()
{


+ 5
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.h View File

@@ -176,6 +176,11 @@ public:
/** Returns true if this context is currently active for the calling thread. */
bool isActive() const noexcept;
/** If any context is active on the current thread, this deactivates it.
Note that on some platforms, like Android, this isn't possible.
*/
static void deactivateCurrentContext();
//==============================================================================
/** Swaps the buffers (if the context can do this).
There's normally no need to call this directly - the buffers will be swapped


Loading…
Cancel
Save