2010-10-12 11:48:58 +00:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2010-10-12 11:48:58 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Intel Corporation.
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-10-12 11:48:58 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
2012-06-20 17:49:08 +00:00
|
|
|
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
|
2010-10-12 11:48:58 +00:00
|
|
|
#error "Only <cogl/cogl.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __COGL_INDICES_H__
|
|
|
|
#define __COGL_INDICES_H__
|
|
|
|
|
2012-02-17 21:46:39 +00:00
|
|
|
/* We forward declare the CoglIndices type here to avoid some circular
|
|
|
|
* dependency issues with the following headers.
|
|
|
|
*/
|
|
|
|
typedef struct _CoglIndices CoglIndices;
|
|
|
|
|
2011-03-02 23:31:19 +00:00
|
|
|
#include <cogl/cogl-index-buffer.h>
|
2010-10-12 11:48:58 +00:00
|
|
|
|
2012-11-22 18:01:10 +00:00
|
|
|
COGL_BEGIN_DECLS
|
2010-10-12 11:48:58 +00:00
|
|
|
|
|
|
|
/**
|
2012-12-30 16:41:43 +00:00
|
|
|
* SECTION:cogl-indices
|
|
|
|
* @short_description: Describe vertex indices stored in a #CoglIndexBuffer.
|
2010-10-12 11:48:58 +00:00
|
|
|
*
|
2011-10-25 20:45:49 +00:00
|
|
|
* Indices allow you to avoid duplicating vertices in your vertex data
|
|
|
|
* by virtualizing your data and instead providing a sequence of index
|
|
|
|
* values that tell the GPU which data should be used for each vertex.
|
|
|
|
*
|
2012-12-30 16:43:17 +00:00
|
|
|
* If the GPU is given a sequence of indices it doesn't simply walk
|
2011-10-25 20:45:49 +00:00
|
|
|
* through each vertex of your data in order it will instead walk
|
|
|
|
* through the indices which can provide random access to the
|
|
|
|
* underlying data.
|
|
|
|
*
|
|
|
|
* Since it's very common to have duplicate vertices when describing a
|
|
|
|
* shape as a list of triangles it can often be a significant space
|
|
|
|
* saving to describe geometry using indices. Reducing the size of
|
|
|
|
* your models can make it cheaper to map them into the GPU by
|
|
|
|
* reducing the demand on memory bandwidth and may help to make better
|
|
|
|
* use of your GPUs internal vertex caching.
|
|
|
|
*
|
|
|
|
* For example, to describe a quadrilateral as 2 triangles for the GPU
|
|
|
|
* you could either provide data with 6 vertices or instead with
|
|
|
|
* indices you can provide vertex data for just 4 vertices and an
|
|
|
|
* index buffer that specfies the 6 vertices by indexing the shared
|
|
|
|
* vertices multiple times.
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* CoglVertex2f quad_vertices[] = {
|
|
|
|
* {x0, y0}, //0 = top left
|
|
|
|
* {x1, y1}, //1 = bottom left
|
|
|
|
* {x2, y2}, //2 = bottom right
|
|
|
|
* {x3, y3}, //3 = top right
|
|
|
|
* };
|
|
|
|
* //tell the gpu how to interpret the quad as 2 triangles...
|
|
|
|
* unsigned char indices[] = {0, 1, 2, 0, 2, 3};
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* Even in the above illustration we see a saving of 10bytes for one
|
|
|
|
* quad compared to having data for 6 vertices and no indices but if
|
|
|
|
* you need to draw 100s or 1000s of quads then its really quite
|
|
|
|
* significant.
|
|
|
|
*
|
|
|
|
* Something else to consider is that often indices can be defined
|
|
|
|
* once and remain static while the vertex data may change for
|
|
|
|
* animations perhaps. That means you may be able to ignore the
|
|
|
|
* negligable cost of mapping your indices into the GPU if they don't
|
|
|
|
* ever change.
|
|
|
|
*
|
|
|
|
* The above illustration is actually a good example of static indices
|
|
|
|
* because it's really common that developers have quad mesh data that
|
|
|
|
* they need to display and we know exactly what that indices array
|
|
|
|
* needs to look like depending on the number of quads that need to be
|
|
|
|
* drawn. It doesn't matter how the quads might be animated and
|
|
|
|
* changed the indices will remain the same. Cogl even has a utility
|
|
|
|
* (cogl_get_rectangle_indices()) to get access to re-useable indices
|
|
|
|
* for drawing quads as above.
|
2010-10-12 11:48:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
CoglIndices *
|
2012-02-06 17:08:58 +00:00
|
|
|
cogl_indices_new (CoglContext *context,
|
|
|
|
CoglIndicesType type,
|
2010-10-12 11:48:58 +00:00
|
|
|
const void *indices_data,
|
|
|
|
int n_indices);
|
|
|
|
|
|
|
|
CoglIndices *
|
2011-03-02 23:31:19 +00:00
|
|
|
cogl_indices_new_for_buffer (CoglIndicesType type,
|
|
|
|
CoglIndexBuffer *buffer,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
size_t offset);
|
2010-10-12 11:48:58 +00:00
|
|
|
|
2011-03-02 23:31:19 +00:00
|
|
|
CoglIndexBuffer *
|
|
|
|
cogl_indices_get_buffer (CoglIndices *indices);
|
2010-11-16 08:41:29 +00:00
|
|
|
|
2010-10-12 11:48:58 +00:00
|
|
|
CoglIndicesType
|
|
|
|
cogl_indices_get_type (CoglIndices *indices);
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
size_t
|
2010-10-12 11:48:58 +00:00
|
|
|
cogl_indices_get_offset (CoglIndices *indices);
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_indices_set_offset (CoglIndices *indices,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
size_t offset);
|
2010-10-12 11:48:58 +00:00
|
|
|
|
|
|
|
CoglIndices *
|
2012-02-06 17:08:58 +00:00
|
|
|
cogl_get_rectangle_indices (CoglContext *context, int n_rectangles);
|
2010-10-12 11:48:58 +00:00
|
|
|
|
2012-03-06 18:21:28 +00:00
|
|
|
/**
|
|
|
|
* cogl_is_indices:
|
|
|
|
* @object: A #CoglObject pointer
|
|
|
|
*
|
|
|
|
* Gets whether the given object references a #CoglIndices.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the object references a #CoglIndices
|
|
|
|
* and %FALSE otherwise.
|
|
|
|
* Since: 1.10
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool
|
2012-03-06 18:21:28 +00:00
|
|
|
cogl_is_indices (void *object);
|
|
|
|
|
2012-11-22 18:01:10 +00:00
|
|
|
COGL_END_DECLS
|
2010-10-12 11:48:58 +00:00
|
|
|
|
|
|
|
#endif /* __COGL_INDICES_H__ */
|
|
|
|
|