Describes the layout of a single vertex attribute within a given CoglVertexArray including:
Note: this is named CoglVertexAttribute not CoglAttribute as it was originally because we might want other kinds of "attributes" in the API later and this could end up being confusing.
cogl_vertex_attribute_new (array, name, type, n_components, stride, offset);
#define cogl_vertex_attribute_new_for_vertex_struct (array, name, type, n_components, VertexType, member)
cogl_vertex_attribute_set_normalized (attrib, TRUE);
How to draw with CoglVertexAttributes:
cogl_vertex_attributes_draw (mode, n_vertices, attrib0, attrib1, ... NULL); cogl_vertex_attributes_draw_range (mode, first_vertex, n_vertices, attrib0, attrib1, ... NULL); cogl_vertex_attributes_draw_with_indices (mode, n_vertices, indices, attrib0, attrib1, ... NULL); cogl_vertex_attributes_draw_range_with_indices (mode, first_vertex, n_vertices, indices, attrib0, attrib1, ... NULL);
Example usage:
attrib = cogl_vertex_attribute_new (array,
"gl_Color",
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
3,
sizeof (MyVertex),
offsetof (MyVertex, red));
cogl_attribute_set_normalized (attrib, TRUE)
/* XXX: I wonder if a macro like this might actually make code a bit confusing to read? * I.e. On initial inspection before you know it's a macro you may be trying to find * where the "x" variable is defined? It's also the same number of arguments as the * raw API which actually seems more self documenting due to the use of "sizeof" and * "offsetof". */ attrib = attribute_new_for_vertex_struct (array, "gl_Color", COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE, 3, MyVertex, x);