mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-22 22:24:56 +08:00
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -622,6 +622,12 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxGLContextBase::ClearCurrent()
|
||||
{
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxGLCanvas
|
||||
// ============================================================================
|
||||
|
||||
@@ -207,4 +207,10 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxGLContextBase::ClearCurrent()
|
||||
{
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
}
|
||||
|
||||
#endif // wxUSE_GLCANVAS
|
||||
|
||||
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user