FLTK logo

[master] f2db90c - Fix "CMake: Fallback to libOpenGL (no-X11 OpenGL)" (#1251)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
[  All Forums  |  Back to fltk.commit  ]
 
[ Previous Message ] [ Next Message ]

[master] f2db90c - Fix "CMake: Fallback to libOpenGL (no-X11 OpenGL)" (#1251) "ManoloFLTK" Nov 02, 2025  
 
commit f2db90cb77466d6720c348be78e491a7d00c9e8c
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sun Nov 2 15:05:38 2025 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sun Nov 2 15:13:29 2025 +0100

    Fix "CMake: Fallback to libOpenGL (no-X11 OpenGL)" (#1251)

 CMake/options.cmake                                | 49 +++++++++++++++-------
 src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H  |  1 +
 .../Wayland/Fl_Wayland_Gl_Window_Driver.cxx        |  7 ++++
 3 files changed, 43 insertions(+), 14 deletions(-)

diff --git CMake/options.cmake CMake/options.cmake
index ea26551..f9855a2 100644
--- CMake/options.cmake
+++ CMake/options.cmake
@@ -642,25 +642,42 @@ if(FLTK_BUILD_GL)
   if(FLTK_USE_WAYLAND)
     pkg_check_modules(WLD_EGL IMPORTED_TARGET wayland-egl)
     pkg_check_modules(PKG_EGL IMPORTED_TARGET egl)
-    pkg_check_modules(PKG_GL  IMPORTED_TARGET gl)
+    if(FLTK_BACKEND_X11)
+      pkg_check_modules(PKG_GL  IMPORTED_TARGET gl)
+    else()
+      pkg_check_modules(PKG_GL  IMPORTED_TARGET opengl)
+    endif()
     pkg_check_modules(PKG_GLU IMPORTED_TARGET glu)
 
     if(NOT (WLD_EGL_FOUND AND PKG_EGL_FOUND AND PKG_GL_FOUND AND PKG_GLU_FOUND))
-      message(STATUS "Modules 'wayland-egl, egl, gl, and glu' are required to build for the Wayland backend.")
+      message(STATUS "Modules 'wayland-egl, egl, gl (or opengl), and glu' are required to build for the Wayland backend.")
       message(FATAL_ERROR "*** Aborting ***")
     endif()
 
   endif(FLTK_USE_WAYLAND)
 
-  if(FLTK_BACKEND_X11)
+  if(FLTK_BACKEND_X11 OR FLTK_USE_WAYLAND)
     set(OPENGL_FOUND TRUE)
-    find_library(OPENGL_LIB GL)
+    if(FLTK_BACKEND_X11)
+      find_library(OPENGL_LIB GL)
+    else()
+      find_library(OPENGL_LIB OpenGL)
+    endif(FLTK_BACKEND_X11)
     get_filename_component(PATH_TO_GLLIB ${OPENGL_LIB} DIRECTORY)
     find_library(GLU_LIB GLU)
     get_filename_component(PATH_TO_GLULIB ${GLU_LIB} DIRECTORY)
-    # FIXME: we should find a better way to resolve this issue:
-    # with GL, must use XQuartz libX11 else "Insufficient GL support"
-    set(OPENGL_LIBRARIES -L${PATH_TO_GLULIB} -L${PATH_TO_GLLIB} -lX11 -lGLU -lGL)
+    set(OPENGL_LIBRARIES -L${PATH_TO_GLULIB} -L${PATH_TO_GLLIB})
+    if(APPLE)
+      # FIXME: we should find a better way to resolve this issue:
+      # with GL, must use XQuartz libX11 else "Insufficient GL support"
+      set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lX11)
+    endif(APPLE)
+    set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lGLU)
+    if(FLTK_BACKEND_X11)
+      set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lGL)
+    else()
+      set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} -lOpenGL)
+    endif(FLTK_BACKEND_X11)
     find_path(OPENGL_INCLUDE_DIR NAMES GL/gl.h OpenGL/gl.h HINTS ${X11_INCLUDE_DIR})
     unset(HAVE_GL_GLU_H CACHE)
     find_file(HAVE_GL_GLU_H GL/glu.h PATHS ${X11_INCLUDE_DIR})
@@ -669,7 +686,7 @@ if(FLTK_BUILD_GL)
     if(APPLE)
       set(HAVE_GL_GLU_H ${HAVE_OPENGL_GLU_H})
     endif(APPLE)
-  endif(FLTK_BACKEND_X11)
+  endif(FLTK_BACKEND_X11 OR FLTK_USE_WAYLAND)
 else(FLTK_BUILD_GL)
   set(OPENGL_FOUND FALSE)
   set(HAVE_GL FALSE)
@@ -711,12 +728,16 @@ if(OPENGL_FOUND)
     list(APPEND GLLIBS -lGLU -lGL)
   endif(WIN32)
 
-  # check if function glXGetProcAddressARB exists
-  set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
-  set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES})
-  check_symbol_exists(glXGetProcAddressARB  "glx.h"   HAVE_GLXGETPROCADDRESSARB)
-  set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES})
-  unset(TEMP_REQUIRED_LIBRARIES)
+  if (FLTK_BACKEND_X11)
+    # check if function glXGetProcAddressARB exists
+    set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+    set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_LIBRARIES})
+    check_symbol_exists(glXGetProcAddressARB  "glx.h"   HAVE_GLXGETPROCADDRESSARB)
+    set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES})
+    unset(TEMP_REQUIRED_LIBRARIES)
+  else()
+    unset(HAVE_GLXGETPROCADDRESSARB CACHE)
+  endif(FLTK_BACKEND_X11)
 endif(OPENGL_FOUND)
 
 #######################################################################
diff --git src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H
index a7622fc..ad67c01 100644
--- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H
+++ src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H
@@ -51,6 +51,7 @@ private:
   void gl_start() FL_OVERRIDE;
   void gl_visual(Fl_Gl_Choice *c) FL_OVERRIDE;
   void init();
+  void* GetProcAddress(const char *procName) FL_OVERRIDE;
 public:
   static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time);
   //virtual bool need_scissor() { return true; } // CONTROL_LEAKING_SUB_GL_WINDOWS
diff --git src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
index 18be681..815196a 100644
--- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx
@@ -22,6 +22,7 @@
 #include "Fl_Wayland_Window_Driver.H"
 #include "Fl_Wayland_Graphics_Driver.H"
 #include "Fl_Wayland_Gl_Window_Driver.H"
+#include "../Posix/Fl_Posix_System_Driver.H"
 #ifdef FLTK_USE_X11
 #  include "../X11/Fl_X11_Gl_Window_Driver.H"
 #endif
@@ -470,6 +471,12 @@ int Fl_Wayland_Gl_Window_Driver::swap_interval() const {
   return swap_interval_;
 }
 
+
+void* Fl_Wayland_Gl_Window_Driver::GetProcAddress(const char *procName) {
+  return Fl_Posix_System_Driver::dlopen_or_dlsym(NULL, procName);
+}
+
+
 FL_EXPORT EGLContext fl_wl_glcontext(GLContext rc) { return (EGLContext)rc; }
 
 #endif // HAVE_GL
[ Direct Link to Message ]
 
     
[ Previous Message ] [ Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.