From 14e6323554d46b5fc25b391fed703efab4266b3b Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Sat, 28 Feb 2009 17:39:38 +0000 Subject: [PATCH] [cogl-vertex-buffer] Allow querying back the number of vertices a buffer represents This may be convenient e.g. at draw time if you are simply drawing all vertices --- clutter/cogl/cogl-vertex-buffer.h | 9 +++++++++ clutter/cogl/common/cogl-vertex-buffer.c | 13 +++++++++++++ doc/reference/cogl/cogl-sections.txt | 1 + 3 files changed, 23 insertions(+) diff --git a/clutter/cogl/cogl-vertex-buffer.h b/clutter/cogl/cogl-vertex-buffer.h index 7988e8e07..4e0006701 100644 --- a/clutter/cogl/cogl-vertex-buffer.h +++ b/clutter/cogl/cogl-vertex-buffer.h @@ -84,6 +84,15 @@ G_BEGIN_DECLS CoglHandle cogl_vertex_buffer_new (guint n_vertices); +/** + * cogl_vertex_buffer_get_n_vertices: + * @handle: A vertex buffer handle + * + * This returns the number of vertices that @handle represents + */ +guint +cogl_vertex_buffer_get_n_vertices (CoglHandle handle); + /** * cogl_vertex_buffer_add: * @handle: A vertex buffer handle diff --git a/clutter/cogl/common/cogl-vertex-buffer.c b/clutter/cogl/common/cogl-vertex-buffer.c index 8a943f4e4..2e9b8749b 100644 --- a/clutter/cogl/common/cogl-vertex-buffer.c +++ b/clutter/cogl/common/cogl-vertex-buffer.c @@ -221,6 +221,19 @@ cogl_vertex_buffer_new (guint n_vertices) return _cogl_vertex_buffer_handle_new (buffer); } +guint +cogl_vertex_buffer_get_n_vertices (CoglHandle handle) +{ + CoglVertexBuffer *buffer; + + if (!cogl_is_vertex_buffer (handle)) + return 0; + + buffer = _cogl_vertex_buffer_pointer_from_handle (handle); + + return buffer->n_vertices; +} + /* There are a number of standard OpenGL attributes that we deal with * specially. These attributes are all namespaced with a "gl_" prefix * so we should catch any typos instead of silently adding a custom diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index 78b3eb2e9..aeefa146f 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -298,6 +298,7 @@ cogl_color_get_alpha_float cogl-vertex-buffer Vertex Buffers cogl_vertex_buffer_new +cogl_vertex_buffer_get_n_vertices cogl_vertex_buffer_ref cogl_vertex_buffer_unref cogl_vertex_buffer_add