Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modern GNU/Linux GLVND OpenGL implementation support. #7562

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 9 additions & 3 deletions backends/imgui_impl_opengl3_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,11 @@ static GL3WglProc (*glx_get_proc_address)(const GLubyte *);

static int open_libgl(void)
{
// Modern post-X11 GLVN-based OpenGL implementation on GNU/Linux uses libOpenGL.so instead of libGL.so used by legacy GLX.
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
libgl = dlopen("libOpenGL.so", RTLD_LAZY | RTLD_LOCAL);
if (!libgl)
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
if (!libgl)
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
if (!libgl)
Expand All @@ -684,8 +687,11 @@ static void close_libgl(void) { dlclose(libgl); }

static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;
res = glx_get_proc_address((const GLubyte *)proc);
GL3WglProc res = NULL;
// Modern post-X11 GLVN-based OpenGL implementation on GNU/Linux doesn't have glxGetProcAddress,
// so watch out for null function pointer.
if (glx_get_proc_address)
res = glx_get_proc_address((const GLubyte *)proc);
if (!res)
*(void **)(&res) = dlsym(libgl, proc);
return res;
Expand Down