Changeset View
Changeset View
Standalone View
Standalone View
libraries/source/glad/src/glx.cpp
/** | |||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0 | |||||
*/ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <glad/glx.h> | #include <glad/glx.h> | ||||
#ifndef GLAD_IMPL_UTIL_C_ | #ifndef GLAD_IMPL_UTIL_C_ | ||||
#define GLAD_IMPL_UTIL_C_ | #define GLAD_IMPL_UTIL_C_ | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | static void glad_glx_load_GLX_SGI_swap_control( GLADuserptrloadfunc load, void* userptr) { | ||||
if(!GLAD_GLX_SGI_swap_control) return; | if(!GLAD_GLX_SGI_swap_control) return; | ||||
glad_glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) load(userptr, "glXSwapIntervalSGI"); | glad_glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) load(userptr, "glXSwapIntervalSGI"); | ||||
} | } | ||||
static int glad_glx_has_extension(Display *display, int screen, const char *ext) { | static int glad_glx_has_extension(Display *display, int screen, const char *ext) { | ||||
#ifndef GLX_VERSION_1_1 | #ifndef GLX_VERSION_1_1 | ||||
(void) display; | GLAD_UNUSED(display); | ||||
(void) screen; | GLAD_UNUSED(screen); | ||||
(void) ext; | GLAD_UNUSED(ext); | ||||
#else | #else | ||||
const char *terminator; | const char *terminator; | ||||
const char *loc; | const char *loc; | ||||
const char *extensions; | const char *extensions; | ||||
if (glXQueryExtensionsString == NULL) { | if (glXQueryExtensionsString == NULL) { | ||||
return 0; | return 0; | ||||
} | } | ||||
Show All 30 Lines | static int glad_glx_find_extensions(Display *display, int screen) { | ||||
GLAD_GLX_SGI_swap_control = glad_glx_has_extension(display, screen, "GLX_SGI_swap_control"); | GLAD_GLX_SGI_swap_control = glad_glx_has_extension(display, screen, "GLX_SGI_swap_control"); | ||||
return 1; | return 1; | ||||
} | } | ||||
static int glad_glx_find_core_glx(Display **display, int *screen) { | static int glad_glx_find_core_glx(Display **display, int *screen) { | ||||
int major = 0, minor = 0; | int major = 0, minor = 0; | ||||
if(*display == NULL) { | if(*display == NULL) { | ||||
#ifdef GLAD_GLX_NO_X11 | #ifdef GLAD_GLX_NO_X11 | ||||
(void) screen; | GLAD_UNUSED(screen); | ||||
return 0; | return 0; | ||||
#else | #else | ||||
*display = XOpenDisplay(0); | *display = XOpenDisplay(0); | ||||
if (*display == NULL) { | if (*display == NULL) { | ||||
return 0; | return 0; | ||||
} | } | ||||
*screen = XScreenNumberOfScreen(XDefaultScreenOfDisplay(*display)); | *screen = XScreenNumberOfScreen(XDefaultScreenOfDisplay(*display)); | ||||
#endif | #endif | ||||
Show All 18 Lines | int gladLoadGLXUserPtr(Display *display, int screen, GLADuserptrloadfunc load, void *userptr) { | ||||
glad_glx_load_GLX_VERSION_1_2(load, userptr); | glad_glx_load_GLX_VERSION_1_2(load, userptr); | ||||
glad_glx_load_GLX_VERSION_1_3(load, userptr); | glad_glx_load_GLX_VERSION_1_3(load, userptr); | ||||
glad_glx_load_GLX_VERSION_1_4(load, userptr); | glad_glx_load_GLX_VERSION_1_4(load, userptr); | ||||
if (!glad_glx_find_extensions(display, screen)) return 0; | if (!glad_glx_find_extensions(display, screen)) return 0; | ||||
glad_glx_load_GLX_MESA_query_renderer(load, userptr); | glad_glx_load_GLX_MESA_query_renderer(load, userptr); | ||||
glad_glx_load_GLX_SGI_swap_control(load, userptr); | glad_glx_load_GLX_SGI_swap_control(load, userptr); | ||||
return version; | return version; | ||||
} | } | ||||
int gladLoadGLX(Display *display, int screen, GLADloadfunc load) { | int gladLoadGLX(Display *display, int screen, GLADloadfunc load) { | ||||
return gladLoadGLXUserPtr(display, screen, glad_glx_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); | return gladLoadGLXUserPtr(display, screen, glad_glx_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); | ||||
} | } | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
#endif | #endif |
Wildfire Games · Phabricator