Corrected the last instance check in OPENGL_GAL.
This commit is contained in:
parent
5850b1ced0
commit
b7ec4ea160
|
@ -51,6 +51,7 @@ static void InitTesselatorCallbacks( GLUtesselator* aTesselator );
|
|||
static const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 };
|
||||
|
||||
wxGLContext* OPENGL_GAL::glMainContext = NULL;
|
||||
int OPENGL_GAL::instanceCounter = 0;
|
||||
GLuint OPENGL_GAL::fontTexture = 0;
|
||||
bool OPENGL_GAL::isBitmapFontLoaded = false;
|
||||
SHADER* OPENGL_GAL::shader = NULL;
|
||||
|
@ -74,6 +75,8 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
|||
glPrivContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this, glMainContext );
|
||||
}
|
||||
|
||||
++instanceCounter;
|
||||
|
||||
// Check if OpenGL requirements are met
|
||||
runTest();
|
||||
|
||||
|
@ -142,6 +145,7 @@ OPENGL_GAL::~OPENGL_GAL()
|
|||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext );
|
||||
|
||||
--instanceCounter;
|
||||
glFlush();
|
||||
gluDeleteTess( tesselator );
|
||||
ClearCache();
|
||||
|
@ -151,9 +155,18 @@ OPENGL_GAL::~OPENGL_GAL()
|
|||
delete nonCachedManager;
|
||||
delete overlayManager;
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext );
|
||||
|
||||
// If it was the main context, then it will be deleted
|
||||
// when the last OpenGL GAL instance is destroyed (a few lines below)
|
||||
if( glPrivContext != glMainContext )
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( glPrivContext );
|
||||
|
||||
// Are destroying the last GAL instance?
|
||||
if( glPrivContext == glMainContext )
|
||||
if( instanceCounter == 0 )
|
||||
{
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( glMainContext );
|
||||
|
||||
if( isBitmapFontLoaded )
|
||||
{
|
||||
glDeleteTextures( 1, &fontTexture );
|
||||
|
@ -161,11 +174,11 @@ OPENGL_GAL::~OPENGL_GAL()
|
|||
}
|
||||
|
||||
delete shader;
|
||||
glMainContext = NULL;
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( glMainContext );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( glMainContext );
|
||||
}
|
||||
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( glPrivContext );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ private:
|
|||
|
||||
static wxGLContext* glMainContext; ///< Parent OpenGL context
|
||||
wxGLContext* glPrivContext; ///< Canvas-specific OpenGL context
|
||||
static int instanceCounter; ///< GL GAL instance counter
|
||||
wxEvtHandler* mouseListener;
|
||||
wxEvtHandler* paintListener;
|
||||
|
||||
|
|
Loading…
Reference in New Issue