From e11ea1b737e91ab23481655a2aea2ed5b90fbbd6 Mon Sep 17 00:00:00 2001 From: Manolo-ES Date: Thu, 22 Sep 2022 20:32:25 +0200 Subject: [PATCH] Fix creating wxGLCanvas with NULL attributes list Using NULL attributes list was not the same as using default wxGLAttributes, but used a platform-dependent set of attributes that was traditionally used by old wxWidgets versions for compatibility. However these attributes didn't specify some important attributes, notably depth buffer size, and relied on OpenGL driver using some reasonable defaults, but this turns out to not be the case any more and resulted in not enabling depth buffer at all, see #22787. Fix this by using the same default attributes as were already used by wxGLAttributes::Defaults() in this case, as this is much more useful, even if not 100%-compatible with the old behaviour. See #22828. --- include/wx/glcanvas.h | 5 ----- src/common/glcmn.cpp | 3 +-- src/msw/glcanvas.cpp | 6 ------ src/osx/glcanvas_osx.cpp | 8 -------- src/qt/glcanvas.cpp | 4 ---- src/unix/glegl.cpp | 6 ------ src/unix/glx11.cpp | 9 --------- 7 files changed, 1 insertion(+), 40 deletions(-) diff --git a/include/wx/glcanvas.h b/include/wx/glcanvas.h index 0ce63fc638..7a26925590 100644 --- a/include/wx/glcanvas.h +++ b/include/wx/glcanvas.h @@ -161,11 +161,6 @@ public: wxGLAttributes& Samplers(int val); wxGLAttributes& FrameBuffersRGB(); void EndList(); // No more values can be chained - - // This function is undocumented and cannot be chained on purpose! - // To keep backwards compatibility with versions before wx3.1 we add here - // the default values used in those versions for the case of NULL list. - void AddDefaultsForWXBefore31(); }; // ---------------------------------------------------------------------------- diff --git a/src/common/glcmn.cpp b/src/common/glcmn.cpp index 28393277b1..09fb3d90c4 100644 --- a/src/common/glcmn.cpp +++ b/src/common/glcmn.cpp @@ -158,8 +158,7 @@ bool wxGLCanvasBase::ParseAttribList(const int *attribList, if ( !attribList ) { - // Default visual attributes used in wx versions before wx3.1 - dispAttrs.AddDefaultsForWXBefore31(); + dispAttrs.Defaults(); dispAttrs.EndList(); if ( ctxAttrs ) ctxAttrs->EndList(); diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp index 66cdb38e97..a28c20b6cd 100644 --- a/src/msw/glcanvas.cpp +++ b/src/msw/glcanvas.cpp @@ -537,12 +537,6 @@ wxGLAttributes& wxGLAttributes::Defaults() return *this; } -void wxGLAttributes::AddDefaultsForWXBefore31() -{ - // ParseAttribList() will add EndList(), don't do it now - RGBA().DoubleBuffer().Depth(16); -} - // ---------------------------------------------------------------------------- // wxGLContext // ---------------------------------------------------------------------------- diff --git a/src/osx/glcanvas_osx.cpp b/src/osx/glcanvas_osx.cpp index 0cafbf5209..07ee0ab4c0 100644 --- a/src/osx/glcanvas_osx.cpp +++ b/src/osx/glcanvas_osx.cpp @@ -356,14 +356,6 @@ wxGLAttributes& wxGLAttributes::Defaults() return *this; } -void wxGLAttributes::AddDefaultsForWXBefore31() -{ - // ParseAttribList() will add EndList(), don't do it now - DoubleBuffer(); - // Negative value will keep its buffer untouched - BufferSize(8).Depth(8).MinRGBA(-1, -1, -1, 0); -} - // ---------------------------------------------------------------------------- // wxGLContext diff --git a/src/qt/glcanvas.cpp b/src/qt/glcanvas.cpp index 2fea936c55..f1f5acbd83 100644 --- a/src/qt/glcanvas.cpp +++ b/src/qt/glcanvas.cpp @@ -327,10 +327,6 @@ wxGLAttributes& wxGLAttributes::Defaults() return *this; } -void wxGLAttributes::AddDefaultsForWXBefore31() -{ - Defaults(); -} //--------------------------------------------------------------------------- // wxGlContext diff --git a/src/unix/glegl.cpp b/src/unix/glegl.cpp index ee6807bb62..582fdfba7b 100644 --- a/src/unix/glegl.cpp +++ b/src/unix/glegl.cpp @@ -275,12 +275,6 @@ wxGLAttributes& wxGLAttributes::Defaults() return *this; } -void wxGLAttributes::AddDefaultsForWXBefore31() -{ - // ParseAttribList() will add EndList(), don't do it now - DoubleBuffer(); -} - // ============================================================================ // wxGLContext implementation diff --git a/src/unix/glx11.cpp b/src/unix/glx11.cpp index b970db5762..f25716e33e 100644 --- a/src/unix/glx11.cpp +++ b/src/unix/glx11.cpp @@ -433,15 +433,6 @@ wxGLAttributes& wxGLAttributes::Defaults() return *this; } -void wxGLAttributes::AddDefaultsForWXBefore31() -{ - // ParseAttribList() will add EndList(), don't do it now - DoubleBuffer(); - if ( wxGLCanvasX11::GetGLXVersion() < 13 ) - RGBA().Depth(1).MinRGBA(1, 1, 1, 0); - // For GLX >= 1.3 its defaults (GLX_RGBA_BIT and GLX_WINDOW_BIT) are OK -} - // ============================================================================ // wxGLContext implementation