Improve virtual void* Fl_Gl_Window_Driver::GetProcAddress(procName)

This commit is contained in:
ManoloFLTK 2022-09-14 08:53:45 +02:00
parent f265ca2afc
commit 700fb1aadd
3 changed files with 19 additions and 19 deletions

View File

@ -521,28 +521,21 @@ char Fl_Gl_Window_Driver::swap_type() {return UNDEFINED;}
void* Fl_Gl_Window_Driver::GetProcAddress(const char *procName) {
#if (HAVE_DLSYM && HAVE_DLFCN_H)
char symbol[1024];
snprintf(symbol, sizeof(symbol), "_%s", procName);
# ifdef RTLD_DEFAULT
return dlsym(RTLD_DEFAULT, symbol);
# else // No RTLD_DEFAULT support, so open the current a.out symbols...
static void *rtld_default = dlopen(0, RTLD_LAZY);
if (rtld_default) return dlsym(rtld_default, symbol);
else return 0;
# endif // RTLD_DEFAULT
#elif defined(HAVE_GLXGETPROCADDRESSARB)
#if defined(HAVE_GLXGETPROCADDRESSARB)
return (void*)glXGetProcAddressARB((const GLubyte *)procName);
#elif (HAVE_DLSYM && HAVE_DLFCN_H)
# ifdef RTLD_DEFAULT
void *rtld_default = RTLD_DEFAULT;
# else
static void *rtld_default = dlopen(0, RTLD_LAZY);
# endif
char symbol[1024];
snprintf(symbol, sizeof(symbol), "_%s", procName);
return dlsym(rtld_default, symbol);
#else
return 0;
#endif // HAVE_DLSYM
return NULL;
}
Fl_Font_Descriptor** Fl_Gl_Window_Driver::fontnum_to_fontdescriptor(int fnum) {

View File

@ -42,6 +42,7 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
virtual char *alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs);
virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h);
virtual bool need_scissor() { return true; }
virtual void* GetProcAddress(const char *procName);
void apply_scissor();
};

View File

@ -25,6 +25,7 @@
#include <FL/Fl_Graphics_Driver.H>
#include <OpenGL/OpenGL.h>
#include <FL/Fl_Image_Surface.H>
#include <dlfcn.h>
extern void gl_texture_reset();
@ -293,6 +294,11 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int
}
void* Fl_Cocoa_Gl_Window_Driver::GetProcAddress(const char *procName) {
return dlsym(RTLD_DEFAULT, procName);
}
FL_EXPORT NSOpenGLContext *fl_mac_glcontext(GLContext rc) {
return (NSOpenGLContext*)rc;
}