Enable GL on Wayland for wx 3.2+, no vsync.
wxWidgets 3.2+ has experimental `wxGLCanvas` support for Wayland EGL, enable it for those versions. The `glXQueryExtensionsString()` method for enabling or disabling vsync does not work on Wayland currently, so it's disabled. TODO: Enable/disable vsync on Wayland EGL. Fix #1028. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
75e46b7117
commit
c27d384a53
|
@ -3707,8 +3707,8 @@ bool MainFrame::BindControls()
|
||||||
#ifdef NO_OGL
|
#ifdef NO_OGL
|
||||||
rb->Hide();
|
rb->Hide();
|
||||||
#endif
|
#endif
|
||||||
#ifdef __WXGTK__
|
#if defined(__WXGTK__) && !wxCHECK_VERSION(3, 2, 0)
|
||||||
// wxGLCanvas segfaults on Wayland
|
// wxGLCanvas segfaults on Wayland before wx 3.2
|
||||||
if (wxGetApp().UsingWayland()) {
|
if (wxGetApp().UsingWayland()) {
|
||||||
rb->Hide();
|
rb->Hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2176,39 +2176,44 @@ void GLDrawingPanel::DrawingPanelInit()
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
// non-portable vsync code
|
// non-portable vsync code
|
||||||
#if defined(__WXGTK__)
|
#if defined(__WXGTK__)
|
||||||
static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL;
|
// TODO: Use Wayland EGL equivalent to enable/disable vsync.
|
||||||
static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
|
if (!IsItWayland()) {
|
||||||
static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA = NULL;
|
static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL;
|
||||||
|
static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
|
||||||
|
static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA = NULL;
|
||||||
|
|
||||||
auto display = GetX11Display();
|
// These wayland checks don't work.
|
||||||
|
auto display = IsItWayland() ? 0 : GetX11Display();
|
||||||
|
auto default_screen = IsItWayland() ? 0 : DefaultScreen(display);
|
||||||
|
|
||||||
char* glxQuery = (char*)glXQueryExtensionsString(display, DefaultScreen(display));
|
char* glxQuery = (char*)glXQueryExtensionsString(display, default_screen);
|
||||||
|
|
||||||
if (strstr(glxQuery, "GLX_EXT_swap_control") != NULL)
|
if (strstr(glxQuery, "GLX_EXT_swap_control") != NULL)
|
||||||
{
|
{
|
||||||
glXSwapIntervalEXT = reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT"));
|
glXSwapIntervalEXT = reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT"));
|
||||||
if (glXSwapIntervalEXT)
|
if (glXSwapIntervalEXT)
|
||||||
glXSwapIntervalEXT(glXGetCurrentDisplay(), glXGetCurrentDrawable(), vsync);
|
glXSwapIntervalEXT(glXGetCurrentDisplay(), glXGetCurrentDrawable(), vsync);
|
||||||
else
|
else
|
||||||
systemScreenMessage(_("Failed to set glXSwapIntervalEXT"));
|
systemScreenMessage(_("Failed to set glXSwapIntervalEXT"));
|
||||||
}
|
}
|
||||||
if (strstr(glxQuery, "GLX_SGI_swap_control") != NULL)
|
if (strstr(glxQuery, "GLX_SGI_swap_control") != NULL)
|
||||||
{
|
{
|
||||||
glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalSGI")));
|
glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalSGI")));
|
||||||
|
|
||||||
if (glXSwapIntervalSGI)
|
if (glXSwapIntervalSGI)
|
||||||
glXSwapIntervalSGI(vsync);
|
glXSwapIntervalSGI(vsync);
|
||||||
else
|
else
|
||||||
systemScreenMessage(_("Failed to set glXSwapIntervalSGI"));
|
systemScreenMessage(_("Failed to set glXSwapIntervalSGI"));
|
||||||
}
|
}
|
||||||
if (strstr(glxQuery, "GLX_MESA_swap_control") != NULL)
|
if (strstr(glxQuery, "GLX_MESA_swap_control") != NULL)
|
||||||
{
|
{
|
||||||
glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalMESA")));
|
glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalMESA")));
|
||||||
|
|
||||||
if (glXSwapIntervalMESA)
|
if (glXSwapIntervalMESA)
|
||||||
glXSwapIntervalMESA(vsync);
|
glXSwapIntervalMESA(vsync);
|
||||||
else
|
else
|
||||||
systemScreenMessage(_("Failed to set glXSwapIntervalMESA"));
|
systemScreenMessage(_("Failed to set glXSwapIntervalMESA"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__WXMSW__)
|
#elif defined(__WXMSW__)
|
||||||
typedef const char* (*wglext)();
|
typedef const char* (*wglext)();
|
||||||
|
|
|
@ -358,10 +358,12 @@ bool wxvbamApp::OnInit() {
|
||||||
|
|
||||||
load_opts();
|
load_opts();
|
||||||
|
|
||||||
// wxGLCanvas segfaults under wayland
|
// wxGLCanvas segfaults under wayland before wx 3.2
|
||||||
|
#if defined(__WXGTK__) && !wxCHECK_VERSION(3, 2, 0)
|
||||||
if (UsingWayland() && gopts.render_method == RND_OPENGL) {
|
if (UsingWayland() && gopts.render_method == RND_OPENGL) {
|
||||||
gopts.render_method = RND_SIMPLE;
|
gopts.render_method = RND_SIMPLE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// process command-line options
|
// process command-line options
|
||||||
for (size_t i = 0; i < pending_optset.size(); i++) {
|
for (size_t i = 0; i < pending_optset.size(); i++) {
|
||||||
|
|
Loading…
Reference in New Issue