[Bf-blender-cvs] [11ffbfb] blender2.8: Gawain: bind a shader for immediate mode

Mike Erwin noreply at git.blender.org
Sun Aug 7 07:37:50 CEST 2016


Commit: 11ffbfb36a94d2a461219e338a6213300b69712d
Author: Mike Erwin
Date:   Sun Aug 7 01:35:42 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB11ffbfb36a94d2a461219e338a6213300b69712d

Gawain: bind a shader for immediate mode

How to use:
1) set up vertex format
2) bind a shader
3) draw with immBegin … immEnd
4) unbind shader

TODO: expand this a little, so we can send uniform values to the bound
shader.

===================================================================

M	source/blender/gpu/GPU_shader.h
M	source/blender/gpu/intern/gpu_shader.c

===================================================================

diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 3950152..9306d7b 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -98,6 +98,8 @@ typedef enum GPUBuiltinShader {
 GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader);
 GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp);
 
+void GPU_shader_bind_immediate(GPUBuiltinShader);
+
 void GPU_shader_free_builtin_shaders(void);
 
 /* Vertex attributes for shaders */
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 896874a..0bd4fcd 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -39,6 +39,7 @@
 #include "GPU_glew.h"
 #include "GPU_shader.h"
 #include "GPU_texture.h"
+#include "GPU_immediate.h"
 
 /* TODO(sergey): Find better default values for this constants. */
 #define MAX_DEFINE_LENGTH 1024
@@ -463,6 +464,13 @@ void GPU_shader_bind(GPUShader *shader)
 	GPU_ASSERT_NO_GL_ERRORS("Post Shader Bind");
 }
 
+void GPU_shader_bind_immediate(GPUBuiltinShader shader_id)
+{
+	GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
+	GPU_shader_bind(shader);
+	bind_attrib_locations(&immVertexFormat, shader->program);
+}
+
 void GPU_shader_unbind(void)
 {
 	GPU_ASSERT_NO_GL_ERRORS("Pre Shader Unbind");




More information about the Bf-blender-cvs mailing list