[Bf-blender-cvs] [031c5ba] blender2.8: Gawain: fix GL_POINTS in immediate mode

Mike Erwin noreply at git.blender.org
Tue Sep 6 21:49:13 CEST 2016


Commit: 031c5bad87693f263d2ee69192fb6f7512a5f6dc
Author: Mike Erwin
Date:   Tue Sep 6 15:45:10 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB031c5bad87693f263d2ee69192fb6f7512a5f6dc

Gawain: fix GL_POINTS in immediate mode

Was using GL_NONE to mean "no primitive" but GL_NONE and GL_POINTS are both defined as 0x0000.

Introducing PRIM_NONE = 0xF which does not clash with any primitive types.

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

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

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

diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 7d32ba3..88a1479 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -36,6 +36,8 @@
   #define glBindVertexArray glBindVertexArrayAPPLE
 #endif
 
+#define PRIM_NONE 0xF
+
 void clear_VertexFormat(VertexFormat* format)
 	{
 	for (unsigned a = 0; a < format->attrib_ct; ++a)
@@ -282,7 +284,7 @@ void immInit()
 	glBufferParameteriAPPLE(GL_ARRAY_BUFFER, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE);
 #endif
 
-	imm.primitive = GL_NONE;
+	imm.primitive = PRIM_NONE;
 	
 	glBindBuffer(GL_ARRAY_BUFFER, 0);
 	glBindVertexArray(0);
@@ -293,7 +295,7 @@ void immDestroy()
 	{
 #if TRUST_NO_ONE
 	assert(initialized);
-	assert(imm.primitive == GL_NONE); // make sure we're not between a Begin/End pair
+	assert(imm.primitive == PRIM_NONE); // make sure we're not between a Begin/End pair
 #endif
 
 	clear_VertexFormat(&imm.vertex_format);
@@ -336,7 +338,7 @@ void immBegin(GLenum primitive, unsigned vertex_ct)
 	{
 #if TRUST_NO_ONE
 	assert(initialized);
-	assert(imm.primitive == GL_NONE); // make sure we haven't already begun
+	assert(imm.primitive == PRIM_NONE); // make sure we haven't already begun
 
 	// does vertex_ct make sense for this primitive type?
 	assert(vertex_ct > 0);
@@ -418,7 +420,7 @@ void immBegin(GLenum primitive, unsigned vertex_ct)
 void immEnd()
 	{
 #if TRUST_NO_ONE
-	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 	assert(imm.vertex_idx == imm.vertex_ct); // with all vertices defined
 #endif
 
@@ -489,7 +491,7 @@ void immEnd()
 
 	// prep for next immBegin
 	imm.buffer_offset += imm.buffer_bytes_mapped;
-	imm.primitive = GL_NONE;
+	imm.primitive = PRIM_NONE;
 
 	// further optional cleanup
 	imm.buffer_bytes_mapped = 0;
@@ -517,7 +519,7 @@ void immAttrib1f(unsigned attrib_id, float x)
 	assert(attrib->comp_type == GL_FLOAT);
 	assert(attrib->comp_ct == 1);
 	assert(imm.vertex_idx < imm.vertex_ct);
-	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 #endif
 
 	setAttribValueBit(attrib_id);
@@ -537,7 +539,7 @@ void immAttrib2f(unsigned attrib_id, float x, float y)
 	assert(attrib->comp_type == GL_FLOAT);
 	assert(attrib->comp_ct == 2);
 	assert(imm.vertex_idx < imm.vertex_ct);
-	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 #endif
 
 	setAttribValueBit(attrib_id);
@@ -558,7 +560,7 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z)
 	assert(attrib->comp_type == GL_FLOAT);
 	assert(attrib->comp_ct == 3);
 	assert(imm.vertex_idx < imm.vertex_ct);
-	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 #endif
 
 	setAttribValueBit(attrib_id);
@@ -580,7 +582,7 @@ void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
 	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
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 #endif
 
 	setAttribValueBit(attrib_id);
@@ -613,7 +615,7 @@ void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
 	assert(attrib->comp_type == GL_UNSIGNED_BYTE);
 	assert(attrib->comp_ct == 3);
 	assert(imm.vertex_idx < imm.vertex_ct);
-	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 #endif
 
 	setAttribValueBit(attrib_id);
@@ -635,7 +637,7 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
 	assert(attrib->comp_type == GL_UNSIGNED_BYTE);
 	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
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 #endif
 
 	setAttribValueBit(attrib_id);
@@ -662,7 +664,7 @@ void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4])
 void immEndVertex()
 	{
 #if TRUST_NO_ONE
-	assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair
+	assert(imm.primitive != PRIM_NONE); // make sure we're between a Begin/End pair
 	assert(imm.vertex_idx < imm.vertex_ct);
 #endif




More information about the Bf-blender-cvs mailing list