1
0
Fork 0

Add cogl_primitive_copy()

This adds a public function to make a copy of a primitive. The copy is
shallow which means it will share the same attributes and attribute
buffers. This could be useful for code that wants to have multiple
similar primitives with slightly modified properties.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2012-02-06 12:52:18 +00:00
parent 55427a18a6
commit 146803c191
3 changed files with 32 additions and 0 deletions

View file

@ -524,6 +524,22 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
primitive->n_vertices = n_indices;
}
CoglPrimitive *
cogl_primitive_copy (CoglPrimitive *primitive)
{
CoglPrimitive *copy;
copy = cogl_primitive_new_with_attributes (primitive->mode,
primitive->n_vertices,
primitive->attributes,
primitive->n_attributes);
cogl_primitive_set_indices (copy, primitive->indices, primitive->n_vertices);
cogl_primitive_set_first_vertex (copy, primitive->first_vertex);
return copy;
}
CoglPrimitive *
_cogl_primitive_immutable_ref (CoglPrimitive *primitive)
{

View file

@ -774,6 +774,21 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
CoglIndices *indices,
int n_indices);
/**
* cogl_primitive_copy:
* @primitive: A primitive copy
*
* Makes a copy of an existing #CoglPrimitive. Note that the primitive
* is a shallow copy which means it will use the same attributes and
* attribute buffers as the original primitive.
*
* Return value: the new primitive
* Since: 1.10
* Stability: unstable
*/
CoglPrimitive *
cogl_primitive_copy (CoglPrimitive *primitive);
/**
* cogl_primitive_draw:
* @primitive: A #CoglPrimitive object

View file

@ -237,6 +237,7 @@ cogl_primitive_set_mode
cogl_primitive_set_attributes
cogl_primitive_set_indices
cogl_primitive_draw
cogl_primitive_copy
</SECTION>
<SECTION>