From 269f420f8d338b1193c94f838eff2916d42d83bc Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 25 Feb 2019 04:51:02 -0800 Subject: [PATCH] OpenGL: Create shaders for each GL Fixes: lp:1817284 * https://bugs.launchpad.net/kicad/+bug/1817284 --- common/gal/opengl/opengl_gal.cpp | 7 +++---- include/gal/opengl/opengl_gal.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 7f450e2207..d68b8c6e7d 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -69,7 +69,6 @@ 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; namespace KIGFX { class GL_BITMAP_CACHE @@ -215,7 +214,6 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, throw std::runtime_error( "Could not create the main OpenGL context" ); glPrivContext = glMainContext; - shader = new SHADER(); } else { @@ -225,6 +223,7 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, throw std::runtime_error( "Could not create a private OpenGL context" ); } + shader = new SHADER(); ++instanceCounter; bitmapCache.reset( new GL_BITMAP_CACHE ); @@ -306,6 +305,8 @@ OPENGL_GAL::~OPENGL_GAL() if( glPrivContext != glMainContext ) GL_CONTEXT_MANAGER::Get().DestroyCtx( glPrivContext ); + delete shader; + // Are we destroying the last GAL instance? if( instanceCounter == 0 ) { @@ -317,8 +318,6 @@ OPENGL_GAL::~OPENGL_GAL() isBitmapFontLoaded = false; } - delete shader; - GL_CONTEXT_MANAGER::Get().UnlockCtx( glMainContext ); GL_CONTEXT_MANAGER::Get().DestroyCtx( glMainContext ); glMainContext = NULL; diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index d14fd0921b..87d72f2c96 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -312,7 +312,7 @@ private: RENDER_TARGET currentTarget; ///< Current rendering target // Shader - static SHADER* shader; ///< There is only one shader used for different objects + SHADER* shader; ///< There is only one shader used for different objects // Internal flags bool isFramebufferInitialized; ///< Are the framebuffers initialized?