diff --git a/gfx/gl.c b/gfx/gl.c index a6e78a2a47..a6d9ab9f83 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1036,7 +1036,7 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo SDL_ShowCursor(SDL_DISABLE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - #if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32) +#if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32) // Win32 GL lib doesn't have some functions needed for XML shaders. // Need to load dynamically :( if (!load_gl_proc()) @@ -1094,7 +1094,7 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo // Set up render to texture. gl_init_fbo(gl, 256 * video->input_scale, 256 * video->input_scale); - + gl->keep_aspect = video->force_aspect; // Apparently need to set viewport for passes when we aren't using FBOs. @@ -1169,7 +1169,7 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo *input = NULL; gl_init_font(gl, g_settings.video.font_path, g_settings.video.font_size); - + if (!gl_check_error()) { SDL_QuitSubSystem(SDL_INIT_VIDEO); @@ -1200,7 +1200,6 @@ static bool gl_xml_shader(void *data, const char *path) //if (!gl_check_error()) // SSNES_WARN("Error happened before deinit!\n"); - gl_shader_deinit(); //if (!gl_check_error()) // SSNES_WARN("Error happened in deinit!\n"); @@ -1220,6 +1219,8 @@ static bool gl_xml_shader(void *data, const char *path) } #endif + gl_shader_deinit(); + //if (!gl_check_error()) // SSNES_WARN("Failed to deinit rendering path properly!\n"); diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 7a7a37e2d8..973af2b03c 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -246,8 +246,9 @@ void gl_cg_set_params(unsigned width, unsigned height, void gl_cg_deinit(void) { - if (cg_active) - cgDestroyContext(cgCtx); + if (!cg_active) + return; + cg_active = false; cg_shader_num = 0; memset(prg, 0, sizeof(prg)); @@ -262,6 +263,8 @@ void gl_cg_deinit(void) snes_tracker_free(snes_tracker); snes_tracker = NULL; } + + cgDestroyContext(cgCtx); } static bool load_plain(const char *path)