diff options
author | Riteo Siuga <riteo@posteo.net> | 2022-11-12 21:46:16 +0100 |
---|---|---|
committer | Riteo <riteo@posteo.net> | 2022-11-15 13:55:30 +0100 |
commit | dc2919d57ba9dd7cea9a525edf37e9b4398b8816 (patch) | |
tree | 466541025b50db8d845ee6e8204dd980c04a88d4 /platform/linuxbsd/x11/gl_manager_x11.cpp | |
parent | 91fcc3986eca5331b4cc44a67adcc2f29a49eb66 (diff) | |
download | redot-engine-dc2919d57ba9dd7cea9a525edf37e9b4398b8816.tar.gz |
Load GLX dynamically with GLAD
This is accomplished through the addition of a GLAD GLX loader in the
`thirdparty` directory.
This is another step towards a nice Wayland/X11 interoperation.
Diffstat (limited to 'platform/linuxbsd/x11/gl_manager_x11.cpp')
-rw-r--r-- | platform/linuxbsd/x11/gl_manager_x11.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp index 893a22e75e..4d8d63c64a 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.cpp +++ b/platform/linuxbsd/x11/gl_manager_x11.cpp @@ -37,9 +37,7 @@ #include <stdlib.h> #include <unistd.h> -#define GLX_GLXEXT_PROTOTYPES -#include <GL/glx.h> -#include <GL/glxext.h> +#include "thirdparty/glad/glad/glx.h" #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 @@ -324,11 +322,14 @@ void GLManager_X11::swap_buffers() { } Error GLManager_X11::initialize() { + if (!gladLoaderLoadGLX(nullptr, 0)) { + return ERR_CANT_CREATE; + } + return OK; } void GLManager_X11::set_use_vsync(bool p_use) { - static bool setup = false; static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = nullptr; static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; @@ -345,25 +346,12 @@ void GLManager_X11::set_use_vsync(bool p_use) { } const GLDisplay &disp = get_current_display(); - if (!setup) { - setup = true; - String extensions = glXQueryExtensionsString(disp.x11_display, DefaultScreen(disp.x11_display)); - if (extensions.find("GLX_EXT_swap_control") != -1) { - glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalEXT"); - } - if (extensions.find("GLX_MESA_swap_control") != -1) { - glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA"); - } - if (extensions.find("GLX_SGI_swap_control") != -1) { - glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI"); - } - } int val = p_use ? 1 : 0; - if (glXSwapIntervalMESA) { + if (GLAD_GLX_MESA_swap_control) { glXSwapIntervalMESA(val); - } else if (glXSwapIntervalSGI) { + } else if (GLAD_GLX_SGI_swap_control) { glXSwapIntervalSGI(val); - } else if (glXSwapIntervalEXT) { + } else if (GLAD_GLX_EXT_swap_control) { GLXDrawable drawable = glXGetCurrentDrawable(); glXSwapIntervalEXT(disp.x11_display, drawable, val); } else { |