40 wxGLContext* context =
new wxGLContext( aCanvas, aOther );
41 wxCHECK( context,
nullptr );
43 if( !context->IsOK() )
49 m_glContexts.insert( std::make_pair( context, aCanvas ) );
88 wxCHECK( aContext &&
m_glContexts.count( aContext ) > 0, );
91 wxGLCanvas* canvas = aCanvas ? aCanvas :
m_glContexts.at( aContext );
97 if( canvas->GTKGetDrawingWindow() )
99 if( canvas->GetXWindow() )
104 canvas->SetCurrent( *aContext );
113 wxCHECK( aContext &&
m_glContexts.count( aContext ) > 0, );
122 wxFAIL_MSG( wxString::Format( wxS(
"Trying to unlock GL context mutex from "
123 "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.