Enable building wxGTK without GLX

GLX support was always built with OpenGL since:
d9df7db130 ("Allow choosing between GLX and EGL during run-time", 2025-12-10)
This commit is contained in:
Chris Mayo
2026-02-02 19:20:34 +00:00
parent 61411f8076
commit 065e639a9d
6 changed files with 18 additions and 9 deletions

View File

@@ -544,6 +544,10 @@ if(wxUSE_GUI)
list(APPEND OPENGL_LIBRARIES ${WAYLANDEGL_LIBRARIES})
endif()
endif()
if(X11_FOUND AND OpenGL_GLX_FOUND)
# toolkit.cmake calls find_package(X11) if X11 support is needed
set(wxHAS_GLX 1)
endif()
if(WXGTK3 AND APPLE AND (NOT wxHAVE_GDK_X11 OR NOT wxHAVE_GDK_WAYLAND))
set(OPENGL_FOUND OFF)
endif()

View File

@@ -1143,6 +1143,9 @@
/* Define if you have EGL support */
#cmakedefine wxHAS_EGL 1
/* Define if you have GLX support */
#cmakedefine wxHAS_GLX 1
/* Define if you have inotify_xxx() functions. */
#cmakedefine wxHAS_INOTIFY 1

View File

@@ -18,14 +18,6 @@
#include "wx/palette.h"
#include "wx/window.h"
// Most ports have a single implementation of wxGLCanvas, but wxGTK has two:
// legacy GLX-based one (also used by wxX11) and EGL-based one which is used
// if support for EGL is available. wxHAS_EGL is defined by the build system
// but define wxHAS_GLX too for consistency, even if it's always available.
#if defined(__WXX11__) || defined(__WXGTK__)
#define wxHAS_GLX 1
#endif
class WXDLLIMPEXP_FWD_GL wxGLCanvas;
class WXDLLIMPEXP_FWD_GL wxGLContext;

View File

@@ -38,6 +38,7 @@ static gboolean draw(GtkWidget* widget, cairo_t* cr, wxGLCanvas* win)
}
#endif // __WXGTK3__
#ifdef wxHAS_GLX
//-----------------------------------------------------------------------------
// emission hook for "parent-set"
//-----------------------------------------------------------------------------
@@ -69,6 +70,7 @@ parent_set_hook(GSignalInvocationHint*, guint, const GValue* param_values, void*
return true;
}
}
#endif // wxHAS_GLX
//---------------------------------------------------------------------------
// wxGlCanvas
@@ -178,6 +180,7 @@ bool wxGLCanvas::Create(wxWindow *parent,
if ( !InitVisual(dispAttrs) )
return false;
#ifdef wxHAS_GLX
// watch for the "parent-set" signal on m_wxwindow so we can set colormap
// before m_wxwindow is realized (which will occur before
// wxWindow::Create() returns if parent is already visible)
@@ -186,6 +189,7 @@ bool wxGLCanvas::Create(wxWindow *parent,
unsigned sig_id = g_signal_lookup("parent-set", GTK_TYPE_WIDGET);
g_signal_add_emission_hook(sig_id, 0, parent_set_hook, this, nullptr);
}
#endif // wxHAS_GLX
wxWindow::Create( parent, id, pos, size, style, name );
#ifdef __WXGTK3__

View File

@@ -23,7 +23,9 @@
#include "wx/glcanvas.h"
#include "wx/unix/private/glcanvas.h"
#ifdef wxHAS_GLX
#include "wx/unix/private/glx11.h"
#endif // wxHAS_GLX
#ifdef wxHAS_EGL
#include "wx/unix/private/glegl.h"
@@ -229,11 +231,15 @@ wxGLBackend* wxGLBackend::Init()
return &wxGLBackendEGL::Get();
#endif // GTK 3 with Wayland
#ifdef wxHAS_GLX
if ( !(wxGLBackendPreferGLX || wxSystemOptions::IsFalse("opengl.egl")) )
#endif // wxHAS_GLX
return &wxGLBackendEGL::Get();
#endif // wxHAS_EGL
#ifdef wxHAS_GLX
return &wxGLBackendX11::Get();
#endif // wxHAS_GLX
}
wxGLContext::wxGLContext(wxGLCanvas *win,

View File

@@ -18,7 +18,7 @@
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_GLCANVAS
#if wxUSE_GLCANVAS && defined(wxHAS_GLX)
#ifndef WX_PRECOMP
#include "wx/log.h"