]> git.lizzy.rs Git - irrlicht.git/blobdiff - source/Irrlicht/CGLXManager.cpp
Reduce IrrCompileConfig usage to files that actually need it
[irrlicht.git] / source / Irrlicht / CGLXManager.cpp
index a72b6a82aea5887235b6ce9068809413643b226e..9a66420e2d6946b4346bbaa49243ab27d10af193 100644 (file)
@@ -7,7 +7,6 @@
 #ifdef _IRR_COMPILE_WITH_GLX_MANAGER_\r
 \r
 #include "os.h"\r
-#include <dlfcn.h>\r
 \r
 #if defined(_IRR_OPENGL_USE_EXTPOINTER_)\r
        #define GL_GLEXT_LEGACY 1\r
@@ -29,7 +28,7 @@ namespace video
 {\r
 \r
 CGLXManager::CGLXManager(const SIrrlichtCreationParameters& params, const SExposedVideoData& videodata, int screennr)\r
-       : Params(params), PrimaryContext(videodata), VisualInfo(0), glxFBConfig(0), GlxWin(0), libHandle(NULL)\r
+       : Params(params), PrimaryContext(videodata), VisualInfo(0), glxFBConfig(0), GlxWin(0)\r
 {\r
        #ifdef _DEBUG\r
        setDebugName("CGLXManager");\r
@@ -280,8 +279,6 @@ bool CGLXManager::initialize(const SIrrlichtCreationParameters& params, const SE
 \r
 void CGLXManager::terminate()\r
 {\r
-       if (libHandle)\r
-               dlclose(libHandle);\r
        memset((void*)&CurrentContext, 0, sizeof(CurrentContext));\r
 }\r
 \r
@@ -311,6 +308,16 @@ void CGLXManager::destroySurface()
                glXDestroyWindow((Display*)CurrentContext.OpenGLLinux.X11Display, GlxWin);\r
 }\r
 \r
+#if defined(GLX_ARB_create_context)\r
+static int IrrIgnoreError(Display *display, XErrorEvent *event)\r
+{\r
+       char msg[256];\r
+       XGetErrorText(display, event->error_code, msg, 256);\r
+       os::Printer::log("Ignoring an X error", msg, ELL_DEBUG);\r
+       return 0;\r
+}\r
+#endif\r
+\r
 bool CGLXManager::generateContext()\r
 {\r
        GLXContext context = 0;\r
@@ -329,13 +336,16 @@ bool CGLXManager::generateContext()
 \r
                        if (glxCreateContextAttribsARB)\r
                        {\r
+                               os::Printer::log("GLX with GLX_ARB_create_context", ELL_DEBUG);\r
                                int contextAttrBuffer[] = {\r
                                        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,\r
                                        GLX_CONTEXT_MINOR_VERSION_ARB, 0,\r
                                        // GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,\r
                                        None\r
                                };\r
+                               XErrorHandler old = XSetErrorHandler(IrrIgnoreError);\r
                                context = glxCreateContextAttribsARB((Display*)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, NULL, True, contextAttrBuffer);\r
+                               XSetErrorHandler(old);\r
                                // transparently fall back to legacy call\r
                        }\r
                        if (!context)\r
@@ -456,15 +466,7 @@ void CGLXManager::destroyContext()
 \r
 void* CGLXManager::getProcAddress(const std::string &procName)\r
 {\r
-       void* proc = NULL;\r
-       proc = (void*)glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(procName.c_str()));\r
-       if (!proc) {\r
-               if (!libHandle)\r
-                       libHandle = dlopen("libGL.so", RTLD_LAZY);\r
-               if (libHandle)\r
-                       proc = dlsym(libHandle, procName.c_str());\r
-       }\r
-       return proc;\r
+       return (void*)glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(procName.c_str()));\r
 }\r
 \r
 bool CGLXManager::swapBuffers()\r