mirror of
https://github.com/flightlessmango/MangoHud.git
synced 2024-11-16 00:13:00 +00:00
[OpenGL] Force-load libGL.so.1 with dlopen() if dlsym fails to find functions
This commit is contained in:
parent
e0ce0493f7
commit
297b44bfe6
@ -162,11 +162,19 @@ void* get_proc_address(const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* get_glx_proc_address(const char* name) {
|
void* get_glx_proc_address(const char* name) {
|
||||||
|
if (!gl.Load()) {
|
||||||
|
// Force load libGL then. If it still doesn't find it, get_proc_address should quit the program
|
||||||
|
void *handle = dlopen("libGL.so.1", RTLD_GLOBAL | RTLD_LAZY | RTLD_DEEPBIND);
|
||||||
|
if (!handle)
|
||||||
|
std::cerr << "MangoHud: couldn't find libGL.so.1" << std::endl;
|
||||||
gl.Load();
|
gl.Load();
|
||||||
|
}
|
||||||
|
|
||||||
void *func = gl.glXGetProcAddress( (const unsigned char*) name );
|
void *func = nullptr;
|
||||||
|
if (gl.glXGetProcAddress)
|
||||||
|
func = gl.glXGetProcAddress( (const unsigned char*) name );
|
||||||
|
|
||||||
if (!func)
|
if (!func && gl.glXGetProcAddressARB)
|
||||||
func = gl.glXGetProcAddressARB( (const unsigned char*) name );
|
func = gl.glXGetProcAddressARB( (const unsigned char*) name );
|
||||||
|
|
||||||
if (!func)
|
if (!func)
|
||||||
@ -297,7 +305,7 @@ EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) {
|
|||||||
if (func)
|
if (func)
|
||||||
return func;
|
return func;
|
||||||
|
|
||||||
return gl.glXGetProcAddress(procName);
|
return get_glx_proc_address((const char*)procName);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) {
|
EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) {
|
||||||
@ -309,7 +317,7 @@ EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) {
|
|||||||
if (func)
|
if (func)
|
||||||
return func;
|
return func;
|
||||||
|
|
||||||
return gl.glXGetProcAddressARB(procName);
|
return get_glx_proc_address((const char*)procName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HOOK_DLSYM
|
#ifdef HOOK_DLSYM
|
||||||
|
Loading…
Reference in New Issue
Block a user