From 8f734ccbb48effa1b9f3057e26ac5eb40ef54930 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 17 Jun 2009 15:03:33 +0100 Subject: [PATCH] [vertex-buffer] Add cogl_vertex_buffer_indices_get_type API cogl_vertex_buffer_indices lets you query back the data type used for the given indices handle. --- clutter/cogl/cogl-vertex-buffer.h | 11 +++++++++++ clutter/cogl/common/cogl-vertex-buffer.c | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/clutter/cogl/cogl-vertex-buffer.h b/clutter/cogl/cogl-vertex-buffer.h index d856f9425..00af95b8b 100644 --- a/clutter/cogl/cogl-vertex-buffer.h +++ b/clutter/cogl/cogl-vertex-buffer.h @@ -332,6 +332,17 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type, const void *indices_array, int indices_len); +/** + * cogl_vertex_buffer_indices_get_type: + * @handle: An indices handle + * + * Queries back the data type used for the given indices + * + * Returns: The CoglIndicesType used + */ +CoglIndicesType +cogl_vertex_buffer_indices_get_type (CoglHandle indices); + /** * cogl_vertex_buffer_delete_indices: * @handle: A vertex buffer handle diff --git a/clutter/cogl/common/cogl-vertex-buffer.c b/clutter/cogl/common/cogl-vertex-buffer.c index ada1d0a19..a18852078 100644 --- a/clutter/cogl/common/cogl-vertex-buffer.c +++ b/clutter/cogl/common/cogl-vertex-buffer.c @@ -1802,6 +1802,27 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type, return _cogl_vertex_buffer_indices_handle_new (indices); } +CoglIndicesType +cogl_vertex_buffer_indices_get_type (CoglHandle indices_handle) +{ + CoglVertexBufferIndices *indices = NULL; + + if (!cogl_is_vertex_buffer_indices (indices_handle)) + return COGL_INDICES_TYPE_UNSIGNED_SHORT; + + indices = _cogl_vertex_buffer_indices_pointer_from_handle (indices_handle); + + if (indices->type == GL_UNSIGNED_BYTE) + return COGL_INDICES_TYPE_UNSIGNED_BYTE; + else if (indices->type == GL_UNSIGNED_SHORT) + return COGL_INDICES_TYPE_UNSIGNED_SHORT; + else + { + g_critical ("unknown indices type %d", indices->type); + return COGL_INDICES_TYPE_UNSIGNED_SHORT; + } +} + void _cogl_vertex_buffer_indices_free (CoglVertexBufferIndices *indices) {