40 wxGLContext* context =
new wxGLContext( aCanvas, aOther );
41 wxCHECK( context,
nullptr );
43#if wxCHECK_VERSION( 3, 1, 0 )
44 if( !context->IsOK() )
51 m_glContexts.insert( std::make_pair( context, aCanvas ) );
90 wxCHECK( aCanvas ||
m_glContexts.count( aContext ) > 0, );
93 wxGLCanvas* canvas = aCanvas ? aCanvas :
m_glContexts.at( aContext );
97 if( canvas->GetXWindow() )
100 canvas->SetCurrent( *aContext );
118 wxFAIL_MSG(
wxString::Format( wxS(
"Trying to unlock GL context mutex from "
119 "a wrong context: aContext %p m_glCtx %p" ), aContext,
m_glCtx ) );
void UnlockCtx(wxGLContext *aContext)
Allow other canvases to bind an OpenGL context.
wxGLContext * m_glCtx
Lock to prevent unexpected GL context switching.
void DestroyCtx(wxGLContext *aContext)
Destroy a managed OpenGL context.
void LockCtx(wxGLContext *aContext, wxGLCanvas *aCanvas)
Set a context as current and prevents other canvases from switching it.
static GL_CONTEXT_MANAGER & Get()
Return the GL_CONTEXT_MANAGER instance (singleton).
std::map< wxGLContext *, wxGLCanvas * > m_glContexts
< Map of GL contexts & their parent canvases.
wxGLContext * CreateCtx(wxGLCanvas *aCanvas, const wxGLContext *aOther=nullptr)
Create a managed OpenGL context.
void DeleteAll()
Destroy all managed OpenGL contexts.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.