[Bf-blender-cvs] [eb717ee] blender2.8: Gawain: more immediate mode functions

Mike Erwin noreply at git.blender.org
Sun Aug 21 04:25:29 CEST 2016


Commit: eb717ee9794a0e3c217f7e6f32904a115fc6e9e1
Author: Mike Erwin
Date:   Sat Aug 20 15:09:32 2016 -0400
Branches: blender2.8
https://developer.blender.org/rBeb717ee9794a0e3c217f7e6f32904a115fc6e9e1

Gawain: more immediate mode functions

Scanned Blender code for commonly used glVertex, glColor functions.
Implemented immVertex, immAttrib versions of these to ease transition
away from legacy OpenGL.

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

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 7c2b35c..08362c3 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -69,9 +69,15 @@ void immEnd(void);
 void immAttrib1f(unsigned attrib_id, float x);
 void immAttrib2f(unsigned attrib_id, float x, float y);
 void immAttrib3f(unsigned attrib_id, float x, float y, float z);
+void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w);
+
+void immAttrib3fv(unsigned attrib_id, const float data[3]);
+void immAttrib4fv(unsigned attrib_id, const float data[4]);
 
 void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b);
 void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+
+void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]);
 void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]);
 
 void immEndVertex(void); // and move on to the next vertex
@@ -79,6 +85,8 @@ 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);
+
+void immVertex2fv(unsigned attrib_id, const float data[2]);
 void immVertex3fv(unsigned attrib_id, const float data[3]);
 
 // provide values that don't change for the entire draw call
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 3065a3e..d250bcc 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -571,6 +571,39 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z)
 	data[2] = z;
 	}
 
+void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
+	{
+	Attrib* attrib = imm.vertex_format.attribs + attrib_id;
+
+#if TRUST_NO_ONE
+	assert(attrib_id < imm.vertex_format.attrib_ct);
+	assert(attrib->comp_type == GL_FLOAT);
+	assert(attrib->comp_ct == 4);
+	assert(imm.vertex_idx < imm.vertex_ct);
+	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+#endif
+
+	setAttribValueBit(attrib_id);
+
+	float* data = (float*)(imm.vertex_data + attrib->offset);
+//	printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data);
+
+	data[0] = x;
+	data[1] = y;
+	data[2] = z;
+	data[3] = w;
+	}
+
+void immAttrib3fv(unsigned attrib_id, const float data[3])
+	{
+	immAttrib3f(attrib_id, data[0], data[1], data[2]);
+	}
+
+void immAttrib4fv(unsigned attrib_id, const float data[4])
+	{
+	immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]);
+	}
+
 void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b)
 	{
 	Attrib* attrib = imm.vertex_format.attribs + attrib_id;
@@ -616,6 +649,11 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
 	data[3] = a;
 	}
 
+void immAttrib3ubv(unsigned attrib_id, const unsigned char data[3])
+	{
+	immAttrib3ub(attrib_id, data[0], data[1], data[2]);
+	}
+
 void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4])
 	{
 	immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
@@ -669,6 +707,12 @@ void immVertex3f(unsigned attrib_id, float x, float y, float z)
 	immEndVertex();
 	}
 
+void immVertex2fv(unsigned attrib_id, const float data[2])
+	{
+	immAttrib2f(attrib_id, data[0], data[1]);
+	immEndVertex();
+	}
+
 void immVertex3fv(unsigned attrib_id, const float data[3])
 	{
 	immAttrib3f(attrib_id, data[0], data[1], data[2]);




More information about the Bf-blender-cvs mailing list