Browse Source

Linux: Fixed some potential deadlocks using OpenGL

tags/2021-05-28
Tom Poole 6 years ago
parent
commit
963e307ef8
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      modules/juce_opengl/native/juce_OpenGL_linux_X11.h

+ 6
- 0
modules/juce_opengl/native/juce_OpenGL_linux_X11.h View File

@@ -154,6 +154,7 @@ public:
void shutdownOnRenderThread()
{
ScopedXLock xlock (display);
context = nullptr;
deactivateCurrentContext();
glXDestroyContext (display, renderContext);
@@ -162,23 +163,27 @@ public:
bool makeActive() const noexcept
{
ScopedXLock xlock (display);
return renderContext != 0
&& glXMakeCurrent (display, embeddedWindow, renderContext);
}
bool isActive() const noexcept
{
ScopedXLock xlock (display);
return glXGetCurrentContext() == renderContext && renderContext != 0;
}
static void deactivateCurrentContext()
{
ScopedXDisplay xDisplay;
ScopedXLock xlock (xDisplay.display);
glXMakeCurrent (xDisplay.display, None, 0);
}
void swapBuffers()
{
ScopedXLock xlock (display);
glXSwapBuffers (display, embeddedWindow);
}
@@ -202,6 +207,7 @@ public:
if (auto GLXSwapIntervalSGI
= (PFNGLXSWAPINTERVALSGIPROC) OpenGLHelpers::getExtensionFunction ("glXSwapIntervalSGI"))
{
ScopedXLock xlock (display);
swapFrames = numFramesPerSwap;
GLXSwapIntervalSGI (numFramesPerSwap);
return true;


Loading…
Cancel
Save