Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions togl/linuxwin/glentrypoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

#if (defined(_LINUX) || defined(PLATFORM_BSD)) && !defined(__ANDROID__)
#include <GL/glx.h>
#include <dlfcn.h>
#endif

// NOTE: This has to be the last file included!
Expand Down Expand Up @@ -301,9 +302,22 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
{
static CDynamicFunctionOpenGL< true, Display *( APIENTRY *)( ), Display* > glXGetCurrentDisplay("glXGetCurrentDisplay");
static CDynamicFunctionOpenGL< true, const char *( APIENTRY *)( Display*, int ), const char * > glXQueryExtensionsString("glXQueryExtensionsString");
if (glXQueryExtensionsString && glXGetCurrentDisplay)
// Under Wayland, SDL uses EGL: there is no GLX context, and the GLX entry
// points returned by SDL_GL_GetProcAddress/eglGetProcAddress are unusable
// stubs. Only query GLX extensions when SDL's video driver is x11.
static int s_bIsX11 = -1;
if (s_bIsX11 < 0)
{
extensions = glXQueryExtensionsString(glXGetCurrentDisplay(), 0);
typedef const char *(*SDL_GetCurrentVideoDriver_t)(void);
SDL_GetCurrentVideoDriver_t pfn = (SDL_GetCurrentVideoDriver_t)dlsym(RTLD_DEFAULT, "SDL_GetCurrentVideoDriver");
const char *drv = pfn ? pfn() : NULL;
s_bIsX11 = (!drv || !strcmp(drv, "x11")) ? 1 : 0;
}
Display *dpy = (s_bIsX11 && glXQueryExtensionsString && glXGetCurrentDisplay) ? glXGetCurrentDisplay() : NULL;
const char *glxext = dpy ? glXQueryExtensionsString(dpy, 0) : NULL;
if (glxext)
{
extensions = glxext;
ptr = strstr(extensions, ext);
}
}
Expand Down