[Bf-blender-cvs] [25e492e] GPU_data_request: new function: bind all attrib locations
Mike Erwin
noreply at git.blender.org
Thu May 14 05:58:17 CEST 2015
Commit: 25e492edaa2cb57999ed229534a36fbeb841cf14
Author: Mike Erwin
Date: Wed May 13 23:57:03 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rB25e492edaa2cb57999ed229534a36fbeb841cf14
new function: bind all attrib locations
Was binding these by hand in wireframe shader tests, but retyping the
name strings is a potential source of errors. Call this function instead
after creating VertexBuffer but before linking the GLSL program.
===================================================================
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 eec2841..2155e00 100644
--- a/source/blender/gpu/GPUx_vbo.h
+++ b/source/blender/gpu/GPUx_vbo.h
@@ -40,6 +40,12 @@ void GPUx_specify_attrib(VertexBuffer*, unsigned attrib_num,
#endif
GLenum comp_type, unsigned comp_ct, VertexFetchMode);
+#ifdef GENERIC_ATTRIB
+/* binds all our named attributes to internally-used GL indices
+ * call this before linking the program */
+void GPUx_bind_attrib_locations(const VertexBuffer*, GLuint program);
+#endif
+
/* 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);
diff --git a/source/blender/gpu/intern/gpux_vbo.c b/source/blender/gpu/intern/gpux_vbo.c
index 84d2697..eab3fec 100644
--- a/source/blender/gpu/intern/gpux_vbo.c
+++ b/source/blender/gpu/intern/gpux_vbo.c
@@ -285,6 +285,20 @@ void GPUx_specify_attrib(VertexBuffer *buff, unsigned attrib_num,
#endif /* PRINT */
}
+#ifdef GENERIC_ATTRIB
+void GPUx_bind_attrib_locations(const VertexBuffer *buff, GLuint program)
+{
+ unsigned a_idx;
+ #ifdef TRUST_NO_ONE
+ BLI_assert(glIsProgram(program));
+ #endif
+ for (a_idx = 0; a_idx < buff->attrib_ct; ++a_idx) {
+ const Attrib *a = buff->attribs + a_idx;
+ glBindAttribLocation(program, a_idx, a->name);
+ }
+}
+#endif /* GENERIC_ATTRIB */
+
void GPUx_set_attrib(VertexBuffer *buff, unsigned attrib_num, unsigned vertex_num, const void *data)
{
Attrib *attrib = buff->attribs + attrib_num;
More information about the Bf-blender-cvs
mailing list