primitive: Add n_indices arg to _set_indices function

When associating indices with a CoglPrimitive you are now forced to
specify the number of indices that should be read when drawing.

It's easy to forget to call cogl_primitive_set_n_vertices() after
associating indices with a primitive (and anyway you can see that someone
could be led to believe Cogl can determine that implicitly somewhow) so
this should avoid a lot of mistakes with using the API.

We'd expect that setting indices and updating the n_vertices property
would go hand in hand 99% of the time anyway so this change should
be more convenient as well as less error prone.

This patch adds some documentation for cogl_primitive_set_indices and
cogl_primitive_get/set_n_vertices. It also tries to clarify how the
CoglPrimitive:n_vertices property is updated and what that property
means in relation to other functions too.

https://bugzilla.gnome.org/show_bug.cgi?id=661019

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg
2011-10-25 22:34:59 +01:00
parent a8fbde4710
commit 8cf76ee36b
4 changed files with 149 additions and 16 deletions

View File

@ -505,7 +505,8 @@ cogl_primitive_set_mode (CoglPrimitive *primitive,
void
cogl_primitive_set_indices (CoglPrimitive *primitive,
CoglIndices *indices)
CoglIndices *indices,
int n_indices)
{
_COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive));
@ -520,6 +521,7 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
if (primitive->indices)
cogl_object_unref (primitive->indices);
primitive->indices = indices;
primitive->n_vertices = n_indices;
}
CoglPrimitive *