-
-
Save wrl/240050fd46e14b688551c75ed2700076 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/third_party/JUCE/modules/juce_opengl/native/juce_OpenGL_linux_X11.h b/third_party/JUCE/modules/juce_opengl/native/juce_OpenGL_linux_X11.h | |
index a5121ce..c9ae234 100644 | |
--- a/third_party/JUCE/modules/juce_opengl/native/juce_OpenGL_linux_X11.h | |
+++ b/third_party/JUCE/modules/juce_opengl/native/juce_OpenGL_linux_X11.h | |
@@ -63,6 +63,8 @@ public: | |
OpenGLVersion) | |
: component (comp), contextToShareWith (shareContext), dummy (*this) | |
{ | |
+ int countFbConfigs; | |
+ | |
display = XWindowSystem::getInstance()->displayRef(); | |
ScopedXLock xlock (display); | |
@@ -70,8 +72,8 @@ public: | |
GLint attribs[] = | |
{ | |
- GLX_RGBA, | |
- GLX_DOUBLEBUFFER, | |
+ GLX_RENDER_TYPE, GLX_RGBA_BIT, | |
+ GLX_DOUBLEBUFFER, True, | |
GLX_RED_SIZE, cPixelFormat.redBits, | |
GLX_GREEN_SIZE, cPixelFormat.greenBits, | |
GLX_BLUE_SIZE, cPixelFormat.blueBits, | |
@@ -82,12 +84,19 @@ public: | |
GLX_ACCUM_GREEN_SIZE, cPixelFormat.accumulationBufferGreenBits, | |
GLX_ACCUM_BLUE_SIZE, cPixelFormat.accumulationBufferBlueBits, | |
GLX_ACCUM_ALPHA_SIZE, cPixelFormat.accumulationBufferAlphaBits, | |
+ GLX_X_RENDERABLE, True, | |
None | |
}; | |
- bestVisual = glXChooseVisual (display, DefaultScreen (display), attribs); | |
- if (bestVisual == nullptr) | |
+ fbConfig = glXChooseFBConfig (display, DefaultScreen (display), attribs, &countFbConfigs); | |
+ if (fbConfig == nullptr) | |
+ return; | |
+ | |
+ bestVisual = glXGetVisualFromFBConfig (display, *fbConfig); | |
+ if (bestVisual == nullptr) { | |
+ XFree (fbConfig); | |
return; | |
+ } | |
auto* peer = component.getPeer(); | |
jassert (peer != nullptr); | |
@@ -120,6 +129,8 @@ public: | |
XMapWindow (display, embeddedWindow); | |
XFreeColormap (display, colourMap); | |
+ glWindow = glXCreateWindow (display, *fbConfig, embeddedWindow, nullptr); | |
+ | |
XSync (display, False); | |
juce_LinuxAddRepaintListener (peer, &dummy); | |
@@ -133,9 +144,13 @@ public: | |
{ | |
ScopedXLock xlock (display); | |
XUnmapWindow (display, embeddedWindow); | |
+ glXDestroyWindow (display, glWindow); | |
XDestroyWindow (display, embeddedWindow); | |
} | |
+ if (fbConfig != nullptr) | |
+ XFree (fbConfig); | |
+ | |
if (bestVisual != nullptr) | |
XFree (bestVisual); | |
@@ -144,8 +159,19 @@ public: | |
bool initialiseOnRenderThread (OpenGLContext& c) | |
{ | |
+ PFNGLXCREATECONTEXTATTRIBSARBPROC createContextAttribs; | |
+ int attribs[] = { | |
+ GLX_CONTEXT_MAJOR_VERSION_ARB, 3, | |
+ GLX_CONTEXT_MINOR_VERSION_ARB, 2, | |
+ GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, | |
+ 0 | |
+ }; | |
+ | |
+ createContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC) | |
+ OpenGLHelpers::getExtensionFunction("glXCreateContextAttribsARB"); | |
+ | |
ScopedXLock xlock (display); | |
- renderContext = glXCreateContext (display, bestVisual, (GLXContext) contextToShareWith, GL_TRUE); | |
+ renderContext = createContextAttribs (display, *fbConfig, (GLXContext) contextToShareWith, True, attribs); | |
c.makeActive(); | |
context = &c; | |
@@ -165,7 +191,7 @@ public: | |
{ | |
ScopedXLock xlock (display); | |
return renderContext != 0 | |
- && glXMakeCurrent (display, embeddedWindow, renderContext); | |
+ && glXMakeContextCurrent (display, glWindow, glWindow, renderContext); | |
} | |
bool isActive() const noexcept | |
@@ -178,13 +204,13 @@ public: | |
{ | |
ScopedXDisplay xDisplay; | |
ScopedXLock xlock (xDisplay.display); | |
- glXMakeCurrent (xDisplay.display, None, 0); | |
+ glXMakeContextCurrent (xDisplay.display, None, None, 0); | |
} | |
void swapBuffers() | |
{ | |
ScopedXLock xlock (display); | |
- glXSwapBuffers (display, embeddedWindow); | |
+ glXSwapBuffers (display, glWindow); | |
} | |
void updateWindowPosition (Rectangle<int> newBounds) | |
@@ -236,9 +262,12 @@ private: | |
int swapFrames = 0; | |
Rectangle<int> bounds; | |
- XVisualInfo* bestVisual = {}; | |
void* contextToShareWith; | |
+ XVisualInfo* bestVisual = {}; | |
+ GLXFBConfig *fbConfig = nullptr; | |
+ GLXWindow glWindow; | |
+ | |
OpenGLContext* context = {}; | |
DummyComponent dummy; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment