mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Use glXGetProcAddress to fetch glXCreateContextAttribsARB. Refs #716
* Most functions we hook and then jump to the real driver we can fetch just with dlsym to the library, but the ARB context creation function is an extension and may not be directly exported. * It's safe to call glXGetProcAddress(ARB) without a context current though and it's guaranteed to be directly exported, so we can use this to fetch the function if we don't find it with dlsym.
This commit is contained in:
@@ -42,6 +42,7 @@ typedef XVisualInfo *(*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display *dpy, GLXFBConfi
|
||||
typedef int (*PFNGLXGETCONFIGPROC)(Display *dpy, XVisualInfo *vis, int attrib, int *value);
|
||||
typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display *dpy, int *errorBase, int *eventBase);
|
||||
typedef Bool (*PFNGLXISDIRECTPROC)(Display *dpy, GLXContext ctx);
|
||||
typedef __GLXextFuncPtr (*PFNGLXGETPROCADDRESSARBPROC)(const GLubyte *procName);
|
||||
|
||||
class OpenGLHook : LibraryHook, public GLPlatform
|
||||
{
|
||||
@@ -363,6 +364,7 @@ public:
|
||||
PFNGLXDESTROYCONTEXTPROC glXDestroyContext_real;
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB_real;
|
||||
PFNGLXGETPROCADDRESSPROC glXGetProcAddress_real;
|
||||
PFNGLXGETPROCADDRESSARBPROC glXGetProcAddressARB_real;
|
||||
PFNGLXMAKECURRENTPROC glXMakeCurrent_real;
|
||||
PFNGLXMAKECONTEXTCURRENTPROC glXMakeContextCurrent_real;
|
||||
PFNGLXSWAPBUFFERSPROC glXSwapBuffers_real;
|
||||
@@ -388,6 +390,9 @@ public:
|
||||
if(glXGetProcAddress_real == NULL)
|
||||
glXGetProcAddress_real =
|
||||
(PFNGLXGETPROCADDRESSPROC)dlsym(libGLdlsymHandle, "glXGetProcAddress");
|
||||
if(glXGetProcAddressARB_real == NULL)
|
||||
glXGetProcAddressARB_real =
|
||||
(PFNGLXGETPROCADDRESSPROC)dlsym(libGLdlsymHandle, "glXGetProcAddressARB");
|
||||
if(glXCreateContext_real == NULL)
|
||||
glXCreateContext_real = (PFNGLXCREATECONTEXTPROC)dlsym(libGLdlsymHandle, "glXCreateContext");
|
||||
if(glXDestroyContext_real == NULL)
|
||||
@@ -418,6 +423,15 @@ public:
|
||||
if(glXQueryDrawable_real == NULL)
|
||||
glXQueryDrawable_real = (PFNGLXQUERYDRAWABLEPROC)dlsym(RTLD_NEXT, "glXQueryDrawable");
|
||||
|
||||
// glXCreateContextAttribsARB may not be directly exported by libGL.so, so try to fetch it
|
||||
// through the glXGetProcAddress function, favouring the ARB variant.
|
||||
if(glXCreateContextAttribsARB_real == NULL && glXGetProcAddressARB_real)
|
||||
glXCreateContextAttribsARB_real = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddressARB_real(
|
||||
(const GLubyte *)"glXCreateContextAttribsARB");
|
||||
if(glXCreateContextAttribsARB_real == NULL && glXGetProcAddress_real)
|
||||
glXCreateContextAttribsARB_real = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress_real(
|
||||
(const GLubyte *)"glXCreateContextAttribsARB");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user