CMakeLists.txt | 1 -
filament/backend/CMakeLists.txt | 10 +-
filament/backend/src/opengl/OpenGLDriver.cpp | 4 +-
- filament/backend/src/opengl/PlatformGLX.cpp | 155 ++++-----------------------
+ filament/backend/src/opengl/PlatformGLX.cpp | 167 ++++++---------------------
filament/backend/src/opengl/PlatformGLX.h | 6 +-
filament/backend/src/opengl/gl_headers.h | 3 +-
- 6 files changed, 36 insertions(+), 143 deletions(-)
+ 6 files changed, 49 insertions(+), 142 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a95c557..5c117c3 100644
#endif
{
diff --git a/filament/backend/src/opengl/PlatformGLX.cpp b/filament/backend/src/opengl/PlatformGLX.cpp
-index b5cb484..665fde3 100644
+index b5cb484..4253f7c 100644
--- a/filament/backend/src/opengl/PlatformGLX.cpp
+++ b/filament/backend/src/opengl/PlatformGLX.cpp
-@@ -20,131 +20,35 @@
+@@ -20,131 +20,41 @@
#include <utils/Panic.h>
#include <X11/Xlib.h>
- g_x11.closeDisplay = (X11_CLOSE_DISPLAY)dlsym(g_x11.library, "XCloseDisplay");
- return true;
-}
--
++#define RESOLVE_GLX_ENTRYPOINT(Function, Type) \
++ Function = (Type)glXGetProcAddress((const GLubyte*)#Function);
+
namespace filament {
using namespace backend;
utils::slog.e << "Failed to open X display. (exiting)." << utils::io::endl;
exit(1);
}
-+ if (glewInit() != GLEW_OK)
-+ {
-+ utils::slog.e << "Failed to initialize GLEW. (exiting)." << utils::io::endl;
-+ exit(1);
-+ }
++ /* Manually resolve glX entrypoints we need to create a context */
++ RESOLVE_GLX_ENTRYPOINT(glXCreateContextAttribsARB, PFNGLXCREATECONTEXTATTRIBSARBPROC);
++ RESOLVE_GLX_ENTRYPOINT(glXCreatePbuffer, PFNGLXCREATEPBUFFERPROC);
++ RESOLVE_GLX_ENTRYPOINT(glXMakeContextCurrent, PFNGLXMAKECONTEXTCURRENTPROC);
++ RESOLVE_GLX_ENTRYPOINT(glXChooseFBConfig, PFNGLXCHOOSEFBCONFIGPROC);
++ RESOLVE_GLX_ENTRYPOINT(glXQueryContext, PFNGLXQUERYCONTEXTPROC);
++ RESOLVE_GLX_ENTRYPOINT(glXGetFBConfigs, PFNGLXGETFBCONFIGSPROC);
++ RESOLVE_GLX_ENTRYPOINT(glXGetFBConfigAttrib, PFNGLXGETFBCONFIGATTRIBPROC);
if (sharedGLContext != nullptr) {
int r = -1;
if (r != 0) {
utils::slog.e << "Failed to get GLX_FBCONFIG_ID from shared GL context."
<< utils::io::endl;
-@@ -152,7 +56,7 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
+@@ -152,7 +62,7 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
}
int numConfigs = 0;
if (fbConfigs == nullptr) {
utils::slog.e << "Failed to get the available GLXFBConfigs." << utils::io::endl;
-@@ -163,7 +67,7 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
+@@ -163,7 +73,7 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
int fbIndex = -1;
for (int i = 0; i < numConfigs; ++i) {
if (r != 0) {
utils::slog.e << "Failed to get GLX_FBCONFIG_ID for entry " << i << "."
<< utils::io::endl;
-@@ -192,29 +96,20 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
+@@ -190,31 +100,21 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
+ GLX_DEPTH_SIZE, 24,
+ None
};
-
+-
int configCount = 0;
- mGLXConfig = g_glx.chooseFbConfig(mGLXDisplay, DefaultScreen(mGLXDisplay),
+ mGLXConfig = glXChooseFBConfig(mGLXDisplay, DefaultScreen(mGLXDisplay),
(GLXContext)sharedGLContext, True, contextAttribs);
int pbufferAttribs[] = {
-@@ -223,21 +118,17 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
+@@ -223,21 +123,26 @@ Driver* PlatformGLX::createDriver(void* const sharedGLContext) noexcept {
GL_NONE
};
- mDummySurface = g_glx.createPbuffer(mGLXDisplay, mGLXConfig[0], pbufferAttribs);
- g_glx.setCurrentContext(mGLXDisplay, mDummySurface, mDummySurface, mGLXContext);
--
-- int result = bluegl::bind();
-- ASSERT_POSTCONDITION(!result, "Unable to load OpenGL entry points.");
+ mDummySurface = glXCreatePbuffer(mGLXDisplay, mGLXConfig[0], pbufferAttribs);
+ glXMakeContextCurrent(mGLXDisplay, mDummySurface, mDummySurface, mGLXContext);
++
++ GLenum result;
++ /* Properly initialize the remainder of the GL entrypoints */
++ if ((result = glewInit()) != GLEW_OK)
++ {
++ utils::slog.e << "Failed to initialize GLEW. (" << result << ", exiting)." << utils::io::endl;
++ exit(1);
++ }
+
+- int result = bluegl::bind();
+- ASSERT_POSTCONDITION(!result, "Unable to load OpenGL entry points.");
return OpenGLDriverFactory::create(this, sharedGLContext);
}
}
Platform::SwapChain* PlatformGLX::createSwapChain(void* nativeWindow, uint64_t& flags) noexcept {
-@@ -255,7 +146,7 @@ Platform::SwapChain* PlatformGLX::createSwapChain(
+@@ -255,7 +160,7 @@ Platform::SwapChain* PlatformGLX::createSwapChain(
GLX_PBUFFER_HEIGHT, int(height),
GL_NONE
};
if (sur) {
mPBuffers.push_back(sur);
}
-@@ -265,19 +156,19 @@ Platform::SwapChain* PlatformGLX::createSwapChain(
+@@ -265,19 +170,19 @@ Platform::SwapChain* PlatformGLX::createSwapChain(
void PlatformGLX::destroySwapChain(Platform::SwapChain* swapChain) noexcept {
auto it = std::find(mPBuffers.begin(), mPBuffers.end(), (GLXPbuffer)swapChain);
if (it != mPBuffers.end()) {