summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-02-06 12:52:18 +0000
committerNeil Roberts <neil@linux.intel.com>2012-02-07 15:25:35 +0000
commit146803c191058330675d493822a331824ab3478a (patch)
tree4b2fd90c7757d0851061bf2df4f4a25ddee32248 /cogl
parent55427a18a611a0006da1ab874dec7a93e760b21b (diff)
downloadcogl-146803c191058330675d493822a331824ab3478a.tar.gz
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>
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl-primitive.c16
-rw-r--r--cogl/cogl-primitive.h15
2 files changed, 31 insertions, 0 deletions
diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c
index a88f1899..10983cd6 100644
--- a/cogl/cogl-primitive.c
+++ b/cogl/cogl-primitive.c
@@ -525,6 +525,22 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
}
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)
{
int i;
diff --git a/cogl/cogl-primitive.h b/cogl/cogl-primitive.h
index c9529a05..62293ab6 100644
--- a/cogl/cogl-primitive.h
+++ b/cogl/cogl-primitive.h
@@ -775,6 +775,21 @@ cogl_primitive_set_indices (CoglPrimitive *primitive,
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
*