From 7f8c1eebea1d9c5cba2aa3b96baceeb4ebed9439 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Wed, 7 Jan 2026 20:48:15 +0100 Subject: [PATCH 1/2] Add option to build against GLVND instead of legacy GLX on GNU/Linux. --- src/gapi/gl.h | 15 ++++++++++++++- src/platform/libretro/Makefile | 9 +++++++++ src/platform/libretro/main.cpp | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/gapi/gl.h b/src/gapi/gl.h index 94f1a252..b529bb1a 100644 --- a/src/gapi/gl.h +++ b/src/gapi/gl.h @@ -300,7 +300,12 @@ extern struct retro_hw_render_callback hw_render; #elif _OS_LINUX && !defined(__LIBRETRO_GLES__) #include #include +#if defined(USE_GLVND) // Modern GL on GNU/Linux is GLVND, and it uses EGL instead of GLX. + #include + extern EGLDisplay display; +#else #include +#endif #elif __APPLE__ #ifdef _OS_IOS #include @@ -376,7 +381,11 @@ extern struct retro_hw_render_callback hw_render; #ifdef _OS_WIN return (void*)wglGetProcAddress(name); #elif _OS_LINUX && !(__LIBRETRO_GLES__) + #if defined(USE_GLVND) + return (void*)eglGetProcAddress(name); + #else return (void*)glXGetProcAddress((GLubyte*)name); + #endif #elif __SDL2__ return (void*)SDL_GL_GetProcAddress(name); #else // EGL @@ -397,7 +406,7 @@ extern struct retro_hw_render_callback hw_render; #ifdef _OS_WIN typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; - #elif _OS_LINUX + #elif _OS_LINUX && !defined(USE_GLVND) typedef int (*PFNGLXSWAPINTERVALSGIPROC) (int interval); PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; #endif @@ -1693,7 +1702,11 @@ namespace GAPI { #ifdef _OS_WIN if (wglSwapIntervalEXT) wglSwapIntervalEXT(enable ? 1 : 0); #elif _OS_LINUX + #if defined(USE_GLVND) + eglSwapInterval(display, enable ? 1 : 0); + #else if (glXSwapIntervalSGI) glXSwapIntervalSGI(enable ? 1 : 0); + #endif #elif defined(__SDL2__) SDL_GL_SetSwapInterval(enable ? 1 : 0); #elif defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_SWITCH) diff --git a/src/platform/libretro/Makefile b/src/platform/libretro/Makefile index 0d982fe5..20de0233 100644 --- a/src/platform/libretro/Makefile +++ b/src/platform/libretro/Makefile @@ -40,7 +40,16 @@ ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined + ##MACMAC + ifeq ($(USE_GLVND), 1) + GL_LIB := -lOpenGL + LIBS += -lEGL + CXXFLAGS += -DUSE_GLVND + CFLAGS += -DUSE_GLVND + else GL_LIB := -lGL + endif + ##MACMAC LIBS += -lpthread CFLAGS += -D_GNU_SOURCE CXXFLAGS += -D_GNU_SOURCE diff --git a/src/platform/libretro/main.cpp b/src/platform/libretro/main.cpp index 480c1e5c..c2fa1955 100644 --- a/src/platform/libretro/main.cpp +++ b/src/platform/libretro/main.cpp @@ -62,6 +62,10 @@ static retro_input_poll_t input_poll_cb; static retro_input_state_t input_cb; static retro_set_rumble_state_t set_rumble_cb; +#ifdef USE_GLVND +EGLDisplay display; +#endif + #ifdef _WIN32 #include #include From bca2b3f454ce8ef506a619733658f3738f622270 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Wed, 7 Jan 2026 20:54:49 +0100 Subject: [PATCH 2/2] Change USE_GLVND to simply GLVND to match other build-time options. --- src/platform/libretro/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/libretro/Makefile b/src/platform/libretro/Makefile index 20de0233..1048ed05 100644 --- a/src/platform/libretro/Makefile +++ b/src/platform/libretro/Makefile @@ -41,7 +41,7 @@ ifeq ($(platform), unix) fpic := -fPIC SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined ##MACMAC - ifeq ($(USE_GLVND), 1) + ifeq ($(GLVND), 1) GL_LIB := -lOpenGL LIBS += -lEGL CXXFLAGS += -DUSE_GLVND