[Bf-blender-cvs] [8e99eec] blender2.8: Gawain: immediate mode set uniforms for active program

Mike Erwin noreply at git.blender.org
Mon Aug 8 10:56:29 CEST 2016


Commit: 8e99eec0260f58fdb86713c96582aa84f6252eac
Author: Mike Erwin
Date:   Sun Aug 7 21:30:02 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB8e99eec0260f58fdb86713c96582aa84f6252eac

Gawain: immediate mode set uniforms for active program

Start simple with vec4 uniforms. Add more later.

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

M	source/blender/gpu/GPU_immediate.h
M	source/blender/gpu/intern/gpu_immediate.c

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

diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index c48abbb6..1373faa 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -58,6 +58,9 @@ extern PER_THREAD VertexFormat immVertexFormat; // so we don't have to copy or p
 void immInit(void);
 void immDestroy(void);
 
+void immBindProgram(GLuint program);
+void immUnbindProgram(void);
+
 void immBegin(GLenum primitive, unsigned vertex_ct);
 void immEnd(void);
 
@@ -73,3 +76,6 @@ void immEndVertex(void); // and move on to the next vertex
 // provide 2D or 3D attribute value and end the current vertex, similar to glVertex:
 void immVertex2f(unsigned attrib_id, float x, float y);
 void immVertex3f(unsigned attrib_id, float x, float y, float z);
+
+// provide values that don't change for the entire draw call
+void immUniform4f(const char* name, float x, float y, float z, float w);
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 80e7877..cea400a 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -187,6 +187,8 @@ typedef struct {
 
 	GLuint vbo_id;
 	GLuint vao_id;
+	
+	GLuint bound_program;
 } Immediate;
 
 // size of internal buffer -- make this adjustable?
@@ -237,6 +239,27 @@ void immDestroy()
 	initialized = false;
 	}
 
+void immBindProgram(GLuint program)
+	{
+#if TRUST_NO_ONE
+	assert(imm.bound_program == 0);
+#endif
+
+	glUseProgram(program);
+	bind_attrib_locations(&immVertexFormat, program);
+	imm.bound_program = program;
+	}
+
+void immUnbindProgram()
+	{
+#if TRUST_NO_ONE
+	assert(imm.bound_program != 0);
+#endif
+
+	glUseProgram(0);
+	imm.bound_program = 0;
+	}
+
 void immBegin(GLenum primitive, unsigned vertex_ct)
 	{
 #if TRUST_NO_ONE
@@ -531,3 +554,14 @@ void immVertex3f(unsigned attrib_id, float x, float y, float z)
 	immAttrib3f(attrib_id, x, y, z);
 	immEndVertex();
 	}
+
+void immUniform4f(const char* name, float x, float y, float z, float w)
+	{
+	int loc = glGetUniformLocation(imm.bound_program, name);
+
+#if TRUST_NO_ONE
+	assert(loc != -1);
+#endif
+
+	glUniform4f(loc, x, y, z, w);
+	}




More information about the Bf-blender-cvs mailing list