mirror of
https://github.com/glfw/glfw.git
synced 2026-11-17 12:19:19 +00:00
Simplified glXGetProcAddress logic.
Removed compile-time selection of GLX entry point retrieval mechanism. Made dlopen a required dependency. This is a stopgap solution until we start requiring GLX 1.4.
This commit is contained in:
@@ -35,11 +35,6 @@
|
||||
// extensions and not all operating systems come with an up-to-date version
|
||||
#include "../deps/EGL/eglext.h"
|
||||
|
||||
// Do we have support for dlopen/dlsym?
|
||||
#if defined(_GLFW_HAS_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#define _GLFW_PLATFORM_FBCONFIG EGLConfig egl
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
|
||||
|
||||
@@ -64,14 +64,6 @@
|
||||
#cmakedefine _GLFW_HAS_XINPUT
|
||||
// Define this to 1 if the Xxf86vm X11 extension is available
|
||||
#cmakedefine _GLFW_HAS_XF86VM
|
||||
// Define this to 1 if glXGetProcAddress is available
|
||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
|
||||
// Define this to 1 if glXGetProcAddressARB is available
|
||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESSARB
|
||||
// Define this to 1 if glXGetProcAddressEXT is available
|
||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT
|
||||
// Define this to 1 if dlopen is available
|
||||
#cmakedefine _GLFW_HAS_DLOPEN
|
||||
|
||||
// Define this to 1 if glfwInit should change the current directory
|
||||
#cmakedefine _GLFW_USE_CHDIR
|
||||
|
||||
+18
-17
@@ -30,11 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
// This is the only glXGetProcAddress variant not declared by glxext.h
|
||||
void (*glXGetProcAddressEXT(const GLubyte* procName))();
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifndef GLXBadProfileARB
|
||||
#define GLXBadProfileARB 13
|
||||
@@ -163,14 +159,17 @@ int _glfwInitContextAPI(void)
|
||||
if (!_glfwInitTLS())
|
||||
return GL_FALSE;
|
||||
|
||||
#ifdef _GLFW_DLOPEN_LIBGL
|
||||
_glfw.glx.libGL = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!_glfw.glx.libGL)
|
||||
_glfw.glx.handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!_glfw.glx.handle)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to find libGL");
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: %s", dlerror());
|
||||
return GL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
_glfw.glx.GetProcAddress =
|
||||
dlsym(_glfw.glx.handle, "glXGetProcAddress");
|
||||
_glfw.glx.GetProcAddressARB =
|
||||
dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
|
||||
|
||||
if (!glXQueryExtension(_glfw.x11.display,
|
||||
&_glfw.glx.errorBase,
|
||||
@@ -257,14 +256,11 @@ int _glfwInitContextAPI(void)
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
{
|
||||
// Unload libGL.so if necessary
|
||||
#ifdef _GLFW_DLOPEN_LIBGL
|
||||
if (_glfw.glx.libGL != NULL)
|
||||
if (_glfw.glx.handle)
|
||||
{
|
||||
dlclose(_glfw.glx.libGL);
|
||||
_glfw.glx.libGL = NULL;
|
||||
dlclose(_glfw.glx.handle);
|
||||
_glfw.glx.handle = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
_glfwTerminateTLS();
|
||||
}
|
||||
@@ -527,7 +523,12 @@ int _glfwPlatformExtensionSupported(const char* extension)
|
||||
|
||||
GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
|
||||
{
|
||||
return _glfw_glXGetProcAddress((const GLubyte*) procname);
|
||||
if (_glfw.glx.GetProcAddress)
|
||||
return _glfw.glx.GetProcAddress((const GLubyte*) procname);
|
||||
else if (_glfw.glx.GetProcAddressARB)
|
||||
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
|
||||
else
|
||||
return dlsym(_glfw.glx.handle, procname);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-26
@@ -34,29 +34,9 @@
|
||||
// This path may need to be changed if you build GLFW using your own setup
|
||||
// We ship and use our own copy of glxext.h since GLFW uses fairly new
|
||||
// extensions and not all operating systems come with an up-to-date version
|
||||
#define GLX_GLXEXT_PROTOTYPES
|
||||
#include "../deps/GL/glxext.h"
|
||||
|
||||
// Do we have support for dlopen/dlsym?
|
||||
#if defined(_GLFW_HAS_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
// We support four different ways for getting addresses for GL/GLX
|
||||
// extension functions: glXGetProcAddress, glXGetProcAddressARB,
|
||||
// glXGetProcAddressEXT, and dlsym
|
||||
#if defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||
#define _glfw_glXGetProcAddress(x) glXGetProcAddressARB(x)
|
||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESS)
|
||||
#define _glfw_glXGetProcAddress(x) glXGetProcAddress(x)
|
||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
|
||||
#define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x)
|
||||
#elif defined(_GLFW_HAS_DLOPEN)
|
||||
#define _glfw_glXGetProcAddress(x) dlsym(_glfw.glx.libGL, x)
|
||||
#define _GLFW_DLOPEN_LIBGL
|
||||
#else
|
||||
#error "No OpenGL entry point retrieval mechanism was enabled"
|
||||
#endif
|
||||
|
||||
#define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx
|
||||
@@ -86,7 +66,12 @@ typedef struct _GLFWlibraryGLX
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
||||
// dlopen handle for libGL.so.1
|
||||
void* handle;
|
||||
|
||||
// GLX extensions
|
||||
PFNGLXGETPROCADDRESSPROC GetProcAddress;
|
||||
PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
|
||||
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
||||
@@ -102,11 +87,6 @@ typedef struct _GLFWlibraryGLX
|
||||
GLboolean EXT_create_context_es2_profile;
|
||||
GLboolean ARB_context_flush_control;
|
||||
|
||||
#if defined(_GLFW_DLOPEN_LIBGL)
|
||||
// dlopen handle for libGL.so (for glfwGetProcAddress)
|
||||
void* libGL;
|
||||
#endif
|
||||
|
||||
} _GLFWlibraryGLX;
|
||||
|
||||
|
||||
|
||||
@@ -797,15 +797,6 @@ const char* _glfwPlatformGetVersionString(void)
|
||||
#elif defined(_GLFW_EGL)
|
||||
" EGL"
|
||||
#endif
|
||||
#if defined(_GLFW_HAS_GLXGETPROCADDRESS)
|
||||
" glXGetProcAddress"
|
||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||
" glXGetProcAddressARB"
|
||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
|
||||
" glXGetProcAddressEXT"
|
||||
#elif defined(_GLFW_DLOPEN_LIBGL)
|
||||
" dlsym(libGL)"
|
||||
#endif
|
||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
" clock_gettime"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user