Merge branch 'gl-release'

Add wxGLContext::ClearCurrent().

See #25958.
This commit is contained in:
Vadim Zeitlin
2025-11-09 01:19:55 +01:00
7 changed files with 48 additions and 3 deletions
+3
View File
@@ -188,6 +188,9 @@ public:
// set this context as the current one
virtual bool SetCurrent(const wxGLCanvas& win) const = 0;
// unset any currently set context
static void ClearCurrent();
bool IsOK() const { return m_isOk; }
protected:
+10
View File
@@ -535,6 +535,16 @@ public:
equivalent, see wxGLCanvas::SetCurrent().
*/
virtual bool SetCurrent(const wxGLCanvas& win) const;
/**
Clears any currently set context.
After calling this function, no OpenGL operations can be performed
until a new context is made current.
@since 3.3.2
*/
static void ClearCurrent();
};
/**
+6
View File
@@ -622,6 +622,12 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
return true;
}
/* static */
void wxGLContextBase::ClearCurrent()
{
wglMakeCurrent(nullptr, nullptr);
}
// ============================================================================
// wxGLCanvas
// ============================================================================
+6
View File
@@ -207,4 +207,10 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
return true;
}
/* static */
void wxGLContextBase::ClearCurrent()
{
[NSOpenGLContext clearCurrentContext];
}
#endif // wxUSE_GLCANVAS
+8
View File
@@ -12,6 +12,7 @@
#include "wx/qt/private/winevent.h"
#include "wx/glcanvas.h"
#include <QOpenGLContext>
#include <QOpenGLWidget>
#include <QSurfaceFormat>
#include <QtWidgets/QGestureRecognizer>
@@ -365,6 +366,13 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
return true;
}
/* static */
void wxGLContextBase::ClearCurrent()
{
if (auto* const current = QOpenGLContext::currentContext())
current->doneCurrent();
}
//---------------------------------------------------------------------------
// PanGestureRecognizer - helper class for wxGLCanvas
//---------------------------------------------------------------------------
+8 -2
View File
@@ -312,8 +312,7 @@ wxGLContext::~wxGLContext()
return;
if ( m_glContext == eglGetCurrentContext() )
eglMakeCurrent(wxGLCanvasEGL::GetDisplay(), EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
ClearCurrent();
eglDestroyContext(wxGLCanvasEGL::GetDisplay(), m_glContext);
}
@@ -327,6 +326,13 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
win.GetEGLSurface(), m_glContext);
}
/* static */
void wxGLContextBase::ClearCurrent()
{
eglMakeCurrent(wxGLCanvasEGL::GetDisplay(), EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
// ============================================================================
// wxGLCanvasEGL implementation
// ============================================================================
+7 -1
View File
@@ -564,7 +564,7 @@ wxGLContext::~wxGLContext()
return;
if ( m_glContext == glXGetCurrentContext() )
MakeCurrent(None, nullptr);
ClearCurrent();
glXDestroyContext( wxGetX11Display(), m_glContext );
}
@@ -580,6 +580,12 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
return MakeCurrent(xid, m_glContext);
}
/* static */
void wxGLContextBase::ClearCurrent()
{
MakeCurrent(None, nullptr);
}
// wrapper around glXMakeContextCurrent/glXMakeCurrent depending on GLX
// version
static bool MakeCurrent(GLXDrawable drawable, GLXContext context)