Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2011-12-23 11:10:01 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-12-23 11:10:01 +0400
commitac498a6b64ea2f034aa0177894fb25d0401e327b (patch)
tree6329247e9ec72875eab97d1d5ca87b74bbea6c50 /source/blender/gpu
parentb59d8c6ba35e43879437e197210bd3900eb56fc9 (diff)
Cleaning up the GPU_extensions_init/exit() code a bit to keep the Blenderplayer from crashing on exit and restart.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c12
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h3
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c17
3 files changed, 25 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 7182bbc38e2..d623697921c 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -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;
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index f52b5bb627e..85bf65232c1 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index eaa661a9dcf..c4ed88635b7 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -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;