Cleaning up the GPU_extensions_init/exit() code a bit to keep the Blenderplayer from crashing on exit and restart.
This commit is contained in:
parent
b59d8c6ba3
commit
ac498a6b64
|
@ -241,7 +241,12 @@ GPUFunction *GPU_lookup_function(const char *name)
|
|||
return (GPUFunction*)BLI_ghash_lookup(FUNCTION_HASH, (void *)name);
|
||||
}
|
||||
|
||||
void GPU_extensions_exit(void)
|
||||
void GPU_codegen_init(void)
|
||||
{
|
||||
GPU_code_generate_glsl_lib();
|
||||
}
|
||||
|
||||
void GPU_codegen_exit(void)
|
||||
{
|
||||
extern Material defmaterial; // render module abuse...
|
||||
|
||||
|
@ -253,8 +258,11 @@ void GPU_extensions_exit(void)
|
|||
FUNCTION_HASH = NULL;
|
||||
}
|
||||
|
||||
if(glsl_material_library)
|
||||
if(glsl_material_library) {
|
||||
MEM_freeN(glsl_material_library);
|
||||
glsl_material_library = NULL;
|
||||
}
|
||||
|
||||
/*if(FUNCTION_PROTOTYPES) {
|
||||
MEM_freeN(FUNCTION_PROTOTYPES);
|
||||
FUNCTION_PROTOTYPES = NULL;
|
||||
|
|
|
@ -178,6 +178,9 @@ void GPU_pass_unbind(GPUPass *pass);
|
|||
|
||||
void GPU_pass_free(GPUPass *pass);
|
||||
|
||||
void GPU_codegen_init(void);
|
||||
void GPU_codegen_exit(void);
|
||||
|
||||
/* Material calls */
|
||||
|
||||
const char *GPU_builtin_name(GPUBuiltin builtin);
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "GPU_draw.h"
|
||||
#include "GPU_extensions.h"
|
||||
#include "gpu_codegen.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -85,6 +86,8 @@ int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
|
|||
|
||||
/* GPU Extensions */
|
||||
|
||||
static int gpu_extensions_init = 0;
|
||||
|
||||
void GPU_extensions_disable(void)
|
||||
{
|
||||
GG.extdisabled = 1;
|
||||
|
@ -96,11 +99,11 @@ void GPU_extensions_init(void)
|
|||
const char *vendor, *renderer;
|
||||
|
||||
/* can't avoid calling this multiple times, see wm_window_add_ghostwindow */
|
||||
static char init= 0;
|
||||
if(init) return;
|
||||
init= 1;
|
||||
if(gpu_extensions_init) return;
|
||||
gpu_extensions_init= 1;
|
||||
|
||||
glewInit();
|
||||
GPU_codegen_init();
|
||||
|
||||
/* glewIsSupported("GL_VERSION_2_0") */
|
||||
|
||||
|
@ -112,8 +115,6 @@ void GPU_extensions_init(void)
|
|||
if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0;
|
||||
if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0;
|
||||
|
||||
GPU_code_generate_glsl_lib();
|
||||
|
||||
glGetIntegerv(GL_RED_BITS, &r);
|
||||
glGetIntegerv(GL_GREEN_BITS, &g);
|
||||
glGetIntegerv(GL_BLUE_BITS, &b);
|
||||
|
@ -188,6 +189,12 @@ void GPU_extensions_init(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void GPU_extensions_exit(void)
|
||||
{
|
||||
gpu_extensions_init = 0;
|
||||
GPU_codegen_exit();
|
||||
}
|
||||
|
||||
int GPU_glsl_support(void)
|
||||
{
|
||||
return !GG.extdisabled && GG.glslsupport;
|
||||
|
|
|
@ -789,6 +789,10 @@ void GPG_Application::stopEngine()
|
|||
|
||||
void GPG_Application::exitEngine()
|
||||
{
|
||||
// We only want to kill the engine if it has been initialized
|
||||
if (!m_engineInitialized)
|
||||
return;
|
||||
|
||||
sound_exit();
|
||||
if (m_ketsjiengine)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue