mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Don't repeatedly dlopen OpenGL library when retrieving address for OpenGL functions
This commit is contained in:
parent
76f25b78b0
commit
cde14930d7
@ -1477,17 +1477,6 @@ cc_result DynamicLib_Get(void* lib, const char* name, void** symbol) {
|
||||
return *symbol == NULL;
|
||||
}
|
||||
|
||||
void* DynamicLib_GetFrom(const char* filename, const char* name) {
|
||||
void* lib;
|
||||
String path;
|
||||
|
||||
path = String_FromReadonly(filename);
|
||||
lib = DynamicLib_Load2(&path);
|
||||
if (!lib) return NULL;
|
||||
|
||||
return DynamicLib_Get2(lib, name);
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||
|
@ -86,7 +86,6 @@ CC_API void* DynamicLib_Load2(const String* path);
|
||||
/* Attempts to get the address of the symbol in the given dynamic library. */
|
||||
/* NOTE: Do NOT use this to load OpenGL functions, use GLContext_GetAddress. */
|
||||
CC_API void* DynamicLib_Get2(void* lib, const char* name);
|
||||
void* DynamicLib_GetFrom(const char* filename, const char* name); /* OBSOLETE */
|
||||
/* Outputs more detailed information about errors with the DynamicLib functions. */
|
||||
/* NOTE: You MUST call this immediately after DynamicLib_Load2/DynamicLib_Get2 returns NULL. */
|
||||
CC_API cc_bool DynamicLib_DescribeError(String* dst);
|
||||
|
14
src/Window.c
14
src/Window.c
@ -4356,7 +4356,12 @@ void GLContext_Free(void) {
|
||||
}
|
||||
|
||||
void* GLContext_GetAddress(const char* function) {
|
||||
void* addr = DynamicLib_GetFrom("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", function);
|
||||
static const String glPath = String_FromConst("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL");
|
||||
static void* lib;
|
||||
void* addr;
|
||||
|
||||
if (!lib) lib = DynamicLib_Load2(&glPath);
|
||||
addr = DynamicLib_Get2(lib, function);
|
||||
return GLContext_IsInvalidAddress(addr) ? NULL : addr;
|
||||
}
|
||||
|
||||
@ -4433,7 +4438,12 @@ void GLContext_Free(void) {
|
||||
}
|
||||
|
||||
void* GLContext_GetAddress(const char* function) {
|
||||
void* addr = DynamicLib_GetFrom("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", function);
|
||||
static const String glPath = String_FromConst("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL");
|
||||
static void* lib;
|
||||
void* addr;
|
||||
|
||||
if (!lib) lib = DynamicLib_Load2(&glPath);
|
||||
addr = DynamicLib_Get2(lib, function);
|
||||
return GLContext_IsInvalidAddress(addr) ? NULL : addr;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user