mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +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:
parent
8309e0ecb0
commit
3c52cb1790
@ -372,25 +372,10 @@ if (_GLFW_GLX)
|
||||
|
||||
list(APPEND glfw_PKG_DEPS "gl")
|
||||
|
||||
include(CheckFunctionExists)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${OPENGL_gl_LIBRARY}")
|
||||
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
|
||||
check_function_exists(glXGetProcAddressARB _GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||
check_function_exists(glXGetProcAddressEXT _GLFW_HAS_GLXGETPROCADDRESSEXT)
|
||||
|
||||
if (NOT _GLFW_HAS_GLXGETPROCADDRESS AND
|
||||
NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND
|
||||
NOT _GLFW_HAS_GLXGETPROCADDRESSEXT)
|
||||
message(WARNING "No glXGetProcAddressXXX variant found")
|
||||
|
||||
set(_GLFW_HAS_DLOPEN 1)
|
||||
if (CMAKE_DL_LIBS)
|
||||
list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
|
||||
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
if (CMAKE_DL_LIBS)
|
||||
list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
|
||||
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
@ -72,6 +72,9 @@ GLFW bundles a number of dependencies in the `deps/` directory.
|
||||
- [Cocoa] Bugfix: Resizing a window to its minimum size would segfault
|
||||
- [Cocoa] Bugfix: Creating or showing a window would make its context current
|
||||
- [X11] Bugfix: `glfwInit` would segfault on systems without RandR
|
||||
- [GLX] Added dependency on `libdl` on systems where it provides `dlopen`
|
||||
- [GLX] Removed `_GLFW_HAS_GLXGETPROCADDRESS*` and `_GLFW_HAS_DLOPEN`
|
||||
compile-time options
|
||||
|
||||
|
||||
## Contact
|
||||
|
@ -288,15 +288,8 @@ libraries.
|
||||
If you are building GLFW as a shared library / dynamic library / DLL then you
|
||||
must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it.
|
||||
|
||||
If you are using the X11 window creation API then you _must_ also select an entry
|
||||
point retrieval mechanism.
|
||||
|
||||
- `_GLFW_HAS_GLXGETPROCADDRESS` to use `glXGetProcAddress` (recommended)
|
||||
- `_GLFW_HAS_GLXGETPROCADDRESSARB` to use `glXGetProcAddressARB` (legacy)
|
||||
- `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy)
|
||||
- `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback)
|
||||
|
||||
In addition, support for the following X11 extensions can be enabled:
|
||||
If you are using the X11 window creation API, support for the following X11
|
||||
extensions can be enabled:
|
||||
|
||||
- `_GLFW_HAS_XINPUT` to use XInput2 for high-resolution cursor motion
|
||||
(recommended)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user