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:
-rw-r--r--source/blender/gpu/GPU_immediate.h8
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c78
2 files changed, 86 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index aeed133645c..c48abbb6388 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -62,6 +62,14 @@ void immBegin(GLenum primitive, unsigned vertex_ct);
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 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 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);
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index e9d19aef3f8..2e4763012ee 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -377,6 +377,27 @@ void immAttrib1f(unsigned attrib_id, float x)
data[0] = x;
}
+void immAttrib2f(unsigned attrib_id, float x, float y)
+ {
+ Attrib* attrib = immVertexFormat.attribs + attrib_id;
+
+#if TRUST_NO_ONE
+ assert(attrib_id < immVertexFormat.attrib_ct);
+ 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
+#endif
+
+ setAttribValueBit(attrib_id);
+
+ float* data = imm.vertex_data + attrib->offset;
+// printf("%s %ld %p\n", __FUNCTION__, (void*)data - imm.buffer_data, data);
+
+ data[0] = x;
+ data[1] = y;
+ }
+
void immAttrib3f(unsigned attrib_id, float x, float y, float z)
{
Attrib* attrib = immVertexFormat.attribs + attrib_id;
@@ -399,6 +420,51 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z)
data[2] = z;
}
+void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b)
+ {
+ Attrib* attrib = immVertexFormat.attribs + attrib_id;
+
+#if TRUST_NO_ONE
+ assert(attrib_id < immVertexFormat.attrib_ct);
+ 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
+#endif
+
+ setAttribValueBit(attrib_id);
+
+ unsigned char* data = imm.vertex_data + attrib->offset;
+// printf("%s %ld %p\n", __FUNCTION__, (void*)data - imm.buffer_data, data);
+
+ data[0] = r;
+ data[1] = g;
+ data[2] = b;
+ }
+
+void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+ {
+ Attrib* attrib = immVertexFormat.attribs + attrib_id;
+
+#if TRUST_NO_ONE
+ assert(attrib_id < immVertexFormat.attrib_ct);
+ 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
+#endif
+
+ setAttribValueBit(attrib_id);
+
+ unsigned char* data = imm.vertex_data + attrib->offset;
+// printf("%s %ld %p\n", __FUNCTION__, (void*)data - imm.buffer_data, data);
+
+ data[0] = r;
+ data[1] = g;
+ data[2] = b;
+ data[3] = a;
+ }
+
void immEndVertex()
{
#if TRUST_NO_ONE
@@ -415,3 +481,15 @@ void immEndVertex()
imm.vertex_data += immVertexFormat.stride;
imm.attrib_value_bits = 0;
}
+
+void immVertex2f(unsigned attrib_id, float x, float y)
+ {
+ immAttrib2f(attrib_id, x, y);
+ immEndVertex();
+ }
+
+void immVertex3f(unsigned attrib_id, float x, float y, float z)
+ {
+ immAttrib3f(attrib_id, x, y, z);
+ immEndVertex();
+ }