[cogl/wip/neil/primitive-updates: 2/6] Add cogl_primitive_copy()
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/neil/primitive-updates: 2/6] Add cogl_primitive_copy()
- Date: Mon, 6 Feb 2012 14:45:56 +0000 (UTC)
commit 1999db06f6a7fde4135f272caec931e34d532f9b
Author: Neil Roberts <neil linux intel com>
Date: Mon Feb 6 12:52:18 2012 +0000
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.
cogl/cogl-primitive.c | 16 ++++++++++++++++
cogl/cogl-primitive.h | 15 +++++++++++++++
.../cogl-2.0-experimental-sections.txt | 1 +
3 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c
index a88f189..10983cd 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 c9529a0..62293ab 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
*
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index a81e201..c6f0c2b 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -237,6 +237,7 @@ cogl_primitive_set_mode
cogl_primitive_set_attributes
cogl_primitive_set_indices
cogl_primitive_draw
+cogl_primitive_copy
</SECTION>
<SECTION>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]