[Bf-blender-cvs] [028adae] GPU_data_request: add vec2f convenience function to GPUx
Mike Erwin
noreply at git.blender.org
Fri Apr 10 04:25:39 CEST 2015
Commit: 028adae2b5f400dd5f0e4ca1cc2fbc5a98b5488b
Author: Mike Erwin
Date: Thu Apr 9 22:13:40 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rB028adae2b5f400dd5f0e4ca1cc2fbc5a98b5488b
add vec2f convenience function to GPUx
===================================================================
M source/blender/gpu/GPUx_vbo.h
M source/blender/gpu/intern/gpux_vbo.c
===================================================================
diff --git a/source/blender/gpu/GPUx_vbo.h b/source/blender/gpu/GPUx_vbo.h
index 1ff6568..27c0f16 100644
--- a/source/blender/gpu/GPUx_vbo.h
+++ b/source/blender/gpu/GPUx_vbo.h
@@ -42,8 +42,9 @@ void GPUx_specify_attrib(VertexBuffer*, unsigned attrib_num,
/* set value of single attribute of single vertex
* incoming data must be of same type & size for this attribute */
void GPUx_set_attrib(VertexBuffer*, unsigned attrib_num, unsigned vertex_num, const void *data);
-/* convenience function for specific type and size
+/* convenience functions for specific type and size
* can add more like this if it's useful */
+void GPUx_set_attrib_2f(VertexBuffer*, unsigned attrib_num, unsigned vertex_num, float x, float y);
void GPUx_set_attrib_3f(VertexBuffer*, unsigned attrib_num, unsigned vertex_num, float x, float y, float z);
/* bulk attribute filling routines (all vertices)
diff --git a/source/blender/gpu/intern/gpux_vbo.c b/source/blender/gpu/intern/gpux_vbo.c
index 36a740b..0df7ac4 100644
--- a/source/blender/gpu/intern/gpux_vbo.c
+++ b/source/blender/gpu/intern/gpux_vbo.c
@@ -267,6 +267,17 @@ void GPUx_set_attrib(VertexBuffer *buff, unsigned attrib_num, unsigned vertex_nu
memcpy((byte*)attrib->data + vertex_num * attrib->stride, data, attrib->sz);
}
+void GPUx_set_attrib_2f(VertexBuffer *buff, unsigned attrib_num, unsigned vertex_num, float x, float y)
+{
+ const GLfloat data[] = { x, y };
+#ifdef TRUST_NO_ONE
+ Attrib *attrib = buff->attribs + attrib_num;
+ assert(attrib->comp_type == GL_FLOAT);
+ assert(attrib->comp_ct == 2);
+#endif /* TRUST_NO_ONE */
+ GPUx_set_attrib(buff, attrib_num, vertex_num, data);
+}
+
void GPUx_set_attrib_3f(VertexBuffer *buff, unsigned attrib_num, unsigned vertex_num, float x, float y, float z)
{
const GLfloat data[] = { x, y, z };
More information about the Bf-blender-cvs
mailing list