[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
This commit is contained in:
Robert Bragg 2009-02-28 17:39:38 +00:00
parent 075ae9c4a7
commit 14e6323554
3 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -298,6 +298,7 @@ cogl_color_get_alpha_float
<FILE>cogl-vertex-buffer</FILE>
<TITLE>Vertex Buffers</TITLE>
cogl_vertex_buffer_new
cogl_vertex_buffer_get_n_vertices
cogl_vertex_buffer_ref
cogl_vertex_buffer_unref
cogl_vertex_buffer_add