1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added method OpenGLContext::deactivateCurrentContext().

This commit is contained in:
jules 2012-05-04 11:23:57 +01:00
parent 54573ae2e5
commit bd0741f9a9
7 changed files with 26 additions and 3 deletions

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; }

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);

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);

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])

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); }

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()
{

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