9#ifndef GLAD_IMPL_UTIL_C_
10#define GLAD_IMPL_UTIL_C_
13#define GLAD_IMPL_UTIL_SSCANF sscanf_s
15#define GLAD_IMPL_UTIL_SSCANF sscanf
134#ifndef GLX_VERSION_1_1
139 const char *terminator;
141 const char *extensions;
149 if(extensions ==
NULL || ext ==
NULL) {
154 loc = strstr(extensions, ext);
158 terminator = loc + strlen(ext);
159 if((loc == extensions || *(loc - 1) ==
' ') &&
160 (*terminator ==
' ' || *terminator ==
'\0')) {
163 extensions = terminator;
180 int major = 0, minor = 0;
181 if(*display ==
NULL) {
182#ifdef GLAD_GLX_NO_X11
186 *display = XOpenDisplay(0);
187 if (*display ==
NULL) {
190 *screen = XScreenNumberOfScreen(XDefaultScreenOfDisplay(*display));
228#ifndef GLAD_LOADER_LIBRARY_C_
229#define GLAD_LOADER_LIBRARY_C_
234#if GLAD_PLATFORM_WIN32
241static void* glad_get_dlopen_handle(
const char *lib_names[],
int length) {
246#if GLAD_PLATFORM_WIN32
247 #if GLAD_PLATFORM_UWP
248 size_t buffer_size = (strlen(lib_names[i]) + 1) *
sizeof(WCHAR);
249 LPWSTR buffer = (LPWSTR)
malloc(buffer_size);
250 if (buffer !=
NULL) {
251 int ret = MultiByteToWideChar(CP_ACP, 0, lib_names[i], -1, buffer, buffer_size);
253 handle = (
void*) LoadPackagedLibrary(buffer, 0);
255 free((
void*) buffer);
258 handle = (
void*) LoadLibraryA(lib_names[i]);
261 handle = dlopen(lib_names[i], RTLD_LAZY | RTLD_LOCAL);
271static void glad_close_dlopen_handle(
void*
handle) {
273#if GLAD_PLATFORM_WIN32
274 FreeLibrary((HMODULE)
handle);
286#if GLAD_PLATFORM_WIN32
295typedef void* (
GLAD_API_PTR *GLADglxprocaddrfunc)(
const char*);
301static void* _glx_handle;
303static void* glad_glx_dlopen_handle(
void) {
304 static const char *NAMES[] = {
305#if defined __CYGWIN__
312 if (_glx_handle ==
NULL) {
313 _glx_handle = glad_get_dlopen_handle(NAMES,
sizeof(NAMES) /
sizeof(NAMES[0]));
323 GLADglxprocaddrfunc loader;
325 did_load = _glx_handle ==
NULL;
326 handle = glad_glx_dlopen_handle();
329 if (loader !=
NULL) {
333 if (!version && did_load) {
343 if (_glx_handle !=
NULL) {
344 glad_close_dlopen_handle(_glx_handle);
GLADapiproc(* GLADuserptrloadfunc)(void *userptr, const char *name)
void(* GLADapiproc)(void)
#define GLAD_MAKE_VERSION(major, minor)
#define GLAD_GNUC_EXTENSION
GLADapiproc(* GLADloadfunc)(const char *name)
static int glad_glx_has_extension(Display *display, int screen, const char *ext)
static void glad_glx_load_GLX_VERSION_1_0(GLADuserptrloadfunc load, void *userptr)
static GLADapiproc glad_glx_get_proc_from_userptr(void *userptr, const char *name)
int gladLoadGLX(Display *display, int screen, GLADloadfunc load)
static void glad_glx_load_GLX_VERSION_1_3(GLADuserptrloadfunc load, void *userptr)
static void glad_glx_load_GLX_VERSION_1_1(GLADuserptrloadfunc load, void *userptr)
static int glad_glx_find_extensions(Display *display, int screen)
int gladLoadGLXUserPtr(Display *display, int screen, GLADuserptrloadfunc load, void *userptr)
static void glad_glx_load_GLX_VERSION_1_4(GLADuserptrloadfunc load, void *userptr)
static void glad_glx_load_GLX_VERSION_1_2(GLADuserptrloadfunc load, void *userptr)
static int glad_glx_find_core_glx(Display **display, int *screen)
PFNGLXQUERYVERSIONPROC glad_glXQueryVersion
int gladLoaderLoadGLX(Display *display, int screen)
GLXContext(* PFNGLXCREATENEWCONTEXTPROC)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct)
PFNGLXDESTROYWINDOWPROC glad_glXDestroyWindow
Bool(* PFNGLXISDIRECTPROC)(Display *dpy, GLXContext ctx)
PFNGLXDESTROYPIXMAPPROC glad_glXDestroyPixmap
PFNGLXUSEXFONTPROC glad_glXUseXFont
Bool(* PFNGLXMAKECONTEXTCURRENTPROC)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
PFNGLXGETVISUALFROMFBCONFIGPROC glad_glXGetVisualFromFBConfig
PFNGLXGETCURRENTDRAWABLEPROC glad_glXGetCurrentDrawable
PFNGLXGETFBCONFIGATTRIBPROC glad_glXGetFBConfigAttrib
PFNGLXCREATENEWCONTEXTPROC glad_glXCreateNewContext
PFNGLXCREATEPIXMAPPROC glad_glXCreatePixmap
PFNGLXQUERYSERVERSTRINGPROC glad_glXQueryServerString
const char *(* PFNGLXGETCLIENTSTRINGPROC)(Display *dpy, int name)
void(* PFNGLXWAITGLPROC)(void)
PFNGLXQUERYCONTEXTPROC glad_glXQueryContext
PFNGLXCREATECONTEXTPROC glad_glXCreateContext
void(* PFNGLXDESTROYGLXPIXMAPPROC)(Display *dpy, GLXPixmap pixmap)
GLXPbuffer(* PFNGLXCREATEPBUFFERPROC)(Display *dpy, GLXFBConfig config, const int *attrib_list)
Bool(* PFNGLXMAKECURRENTPROC)(Display *dpy, GLXDrawable drawable, GLXContext ctx)
PFNGLXDESTROYPBUFFERPROC glad_glXDestroyPbuffer
int(* PFNGLXGETCONFIGPROC)(Display *dpy, XVisualInfo *visual, int attrib, int *value)
__GLXextFuncPtr(* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName)
GLXFBConfig *(* PFNGLXCHOOSEFBCONFIGPROC)(Display *dpy, int screen, const int *attrib_list, int *nelements)
int(* PFNGLXQUERYCONTEXTPROC)(Display *dpy, GLXContext ctx, int attribute, int *value)
void(* PFNGLXDESTROYPBUFFERPROC)(Display *dpy, GLXPbuffer pbuf)
Bool(* PFNGLXQUERYVERSIONPROC)(Display *dpy, int *maj, int *min)
Display *(* PFNGLXGETCURRENTDISPLAYPROC)(void)
PFNGLXCOPYCONTEXTPROC glad_glXCopyContext
PFNGLXCHOOSEVISUALPROC glad_glXChooseVisual
GLXContext(* PFNGLXCREATECONTEXTPROC)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct)
PFNGLXSWAPBUFFERSPROC glad_glXSwapBuffers
PFNGLXGETCONFIGPROC glad_glXGetConfig
PFNGLXWAITGLPROC glad_glXWaitGL
void gladLoaderUnloadGLX(void)
int GLAD_GLX_ARB_multisample
XVisualInfo *(* PFNGLXGETVISUALFROMFBCONFIGPROC)(Display *dpy, GLXFBConfig config)
void(* PFNGLXCOPYCONTEXTPROC)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
PFNGLXQUERYDRAWABLEPROC glad_glXQueryDrawable
void(* PFNGLXSWAPBUFFERSPROC)(Display *dpy, GLXDrawable drawable)
PFNGLXGETPROCADDRESSPROC glad_glXGetProcAddress
GLXPixmap(* PFNGLXCREATEPIXMAPPROC)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list)
PFNGLXQUERYEXTENSIONPROC glad_glXQueryExtension
int(* PFNGLXGETFBCONFIGATTRIBPROC)(Display *dpy, GLXFBConfig config, int attribute, int *value)
PFNGLXGETCLIENTSTRINGPROC glad_glXGetClientString
const char *(* PFNGLXQUERYSERVERSTRINGPROC)(Display *dpy, int screen, int name)
PFNGLXSELECTEVENTPROC glad_glXSelectEvent
PFNGLXQUERYEXTENSIONSSTRINGPROC glad_glXQueryExtensionsString
PFNGLXDESTROYCONTEXTPROC glad_glXDestroyContext
void(* PFNGLXDESTROYWINDOWPROC)(Display *dpy, GLXWindow win)
PFNGLXCHOOSEFBCONFIGPROC glad_glXChooseFBConfig
const char *(* PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display *dpy, int screen)
void(* PFNGLXSELECTEVENTPROC)(Display *dpy, GLXDrawable draw, unsigned long event_mask)
PFNGLXMAKECURRENTPROC glad_glXMakeCurrent
GLXFBConfig *(* PFNGLXGETFBCONFIGSPROC)(Display *dpy, int screen, int *nelements)
GLXWindow(* PFNGLXCREATEWINDOWPROC)(Display *dpy, GLXFBConfig config, Window win, const int *attrib_list)
PFNGLXGETSELECTEDEVENTPROC glad_glXGetSelectedEvent
GLXDrawable(* PFNGLXGETCURRENTDRAWABLEPROC)(void)
PFNGLXISDIRECTPROC glad_glXIsDirect
void(* PFNGLXDESTROYCONTEXTPROC)(Display *dpy, GLXContext ctx)
GLXPixmap(* PFNGLXCREATEGLXPIXMAPPROC)(Display *dpy, XVisualInfo *visual, Pixmap pixmap)
void(* PFNGLXUSEXFONTPROC)(Font font, int first, int count, int list)
GLXDrawable(* PFNGLXGETCURRENTREADDRAWABLEPROC)(void)
void(* PFNGLXDESTROYPIXMAPPROC)(Display *dpy, GLXPixmap pixmap)
PFNGLXGETCURRENTREADDRAWABLEPROC glad_glXGetCurrentReadDrawable
PFNGLXGETCURRENTDISPLAYPROC glad_glXGetCurrentDisplay
PFNGLXMAKECONTEXTCURRENTPROC glad_glXMakeContextCurrent
GLXContext(* PFNGLXGETCURRENTCONTEXTPROC)(void)
PFNGLXCREATEWINDOWPROC glad_glXCreateWindow
#define glXQueryExtensionsString
PFNGLXDESTROYGLXPIXMAPPROC glad_glXDestroyGLXPixmap
PFNGLXCREATEPBUFFERPROC glad_glXCreatePbuffer
Bool(* PFNGLXQUERYEXTENSIONPROC)(Display *dpy, int *errorb, int *event)
void(* PFNGLXQUERYDRAWABLEPROC)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
PFNGLXGETCURRENTCONTEXTPROC glad_glXGetCurrentContext
void(* PFNGLXWAITXPROC)(void)
PFNGLXGETFBCONFIGSPROC glad_glXGetFBConfigs
XVisualInfo *(* PFNGLXCHOOSEVISUALPROC)(Display *dpy, int screen, int *attribList)
PFNGLXCREATEGLXPIXMAPPROC glad_glXCreateGLXPixmap
PFNGLXWAITXPROC glad_glXWaitX
void(* PFNGLXGETSELECTEDEVENTPROC)(Display *dpy, GLXDrawable draw, unsigned long *event_mask)
loader
Declare DataLoader(s).
BVH_ALWAYS_INLINE T length(const Vec< T, N > &v)