[cogl-vertex-buffer] Seal GL types from the public API
We now have CoglAttributeType and CoglVerticesMode typedefs to replace the use of GLenum in the public API.
This commit is contained in:
parent
58b89eabdf
commit
e4d820b75d
2 changed files with 93 additions and 73 deletions
|
@ -94,6 +94,24 @@ cogl_vertex_buffer_new (guint n_vertices);
|
|||
guint
|
||||
cogl_vertex_buffer_get_n_vertices (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* CoglAttributeType:
|
||||
* @COGL_ATTRIBUTE_TYPE_BYTE:
|
||||
* @COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE:
|
||||
* @COGL_ATTRIBUTE_TYPE_SHORT:
|
||||
* @COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT:
|
||||
* @COGL_ATTRIBUTE_TYPE_FLOAT:
|
||||
*
|
||||
*/
|
||||
typedef enum _CoglAttributeType
|
||||
{
|
||||
COGL_ATTRIBUTE_TYPE_BYTE = GL_BYTE,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE = GL_UNSIGNED_BYTE,
|
||||
COGL_ATTRIBUTE_TYPE_SHORT = GL_SHORT,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT = GL_UNSIGNED_SHORT,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT = GL_FLOAT
|
||||
} CoglAttributeType;
|
||||
|
||||
/**
|
||||
* cogl_vertex_buffer_add:
|
||||
* @handle: A vertex buffer handle
|
||||
|
@ -111,10 +129,9 @@ cogl_vertex_buffer_get_n_vertices (CoglHandle handle);
|
|||
* the name can have a detail component, E.g.
|
||||
* "gl_Color::active" or "gl_Color::inactive"
|
||||
* @n_components: The number of components per attribute and must be 1,2,3 or 4
|
||||
* @gl_type: Specifies the data type of each component (GL_BYTE, GL_UNSIGNED_BYTE,
|
||||
* GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT or GL_FLOAT)
|
||||
* @type: a #CoglAttributeType specifying the data type of each component.
|
||||
* @normalized: If GL_TRUE, this specifies that values stored in an integer
|
||||
* format should be mapped into the range [-1.0, 1.0] or [0.1, 1.0]
|
||||
* format should be mapped into the range [-1.0, 1.0] or [0.0, 1.0]
|
||||
* for unsigned values. If GL_FALSE they are converted to floats
|
||||
* directly.
|
||||
* @stride: This specifies the number of bytes from the start of one attribute
|
||||
|
@ -156,13 +173,13 @@ cogl_vertex_buffer_get_n_vertices (CoglHandle handle);
|
|||
* (Though you can have multiple groups of interleved attributes)
|
||||
*/
|
||||
void
|
||||
cogl_vertex_buffer_add (CoglHandle handle,
|
||||
const char *attribute_name,
|
||||
guint8 n_components,
|
||||
GLenum gl_type,
|
||||
gboolean normalized,
|
||||
guint16 stride,
|
||||
const void *pointer);
|
||||
cogl_vertex_buffer_add (CoglHandle handle,
|
||||
const char *attribute_name,
|
||||
guint8 n_components,
|
||||
CoglAttributeType type,
|
||||
gboolean normalized,
|
||||
guint16 stride,
|
||||
const void *pointer);
|
||||
|
||||
/**
|
||||
* cogl_vertex_buffer_delete:
|
||||
|
@ -226,21 +243,33 @@ void
|
|||
cogl_vertex_buffer_enable (CoglHandle handle,
|
||||
const char *attribute_name);
|
||||
|
||||
/**
|
||||
* CoglVerticesMode:
|
||||
* COGL_VERTICES_MODE_POINTS:
|
||||
* COGL_VERTICES_MODE_LINE_STRIP:
|
||||
* COGL_VERTICES_MODE_LINE_LOOP:
|
||||
* COGL_VERTICES_MODE_LINES:
|
||||
* COGL_VERTICES_MODE_TRIANGLE_STRIP:
|
||||
* COGL_VERTICES_MODE_TRIANGLE_FAN:
|
||||
* COGL_VERTICES_MODE_TRIANGLES:
|
||||
*
|
||||
*/
|
||||
typedef enum _CoglVerticesMode
|
||||
{
|
||||
COGL_VERTICES_MODE_POINTS = GL_POINTS,
|
||||
COGL_VERTICES_MODE_LINE_STRIP = GL_LINE_STRIP,
|
||||
COGL_VERTICES_MODE_LINE_LOOP = GL_LINE_LOOP,
|
||||
COGL_VERTICES_MODE_LINES = GL_LINES,
|
||||
COGL_VERTICES_MODE_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
|
||||
COGL_VERTICES_MODE_TRIANGLE_FAN = GL_TRIANGLE_FAN,
|
||||
COGL_VERTICES_MODE_TRIANGLES = GL_TRIANGLES
|
||||
} CoglVerticesMode;
|
||||
|
||||
/**
|
||||
* cogl_vertex_buffer_draw:
|
||||
* @handle: A vertex buffer handle
|
||||
* @mode: Specifies how the vertices should be interpreted, and should be
|
||||
* a valid GL primitive type:
|
||||
* <itemizedlist>
|
||||
* <listitem>GL_POINTS</listitem>
|
||||
* <listitem>GL_LINE_STRIP</listitem>
|
||||
* <listitem>GL_LINE_LOOP</listitem>
|
||||
* <listitem>GL_LINES</listitem>
|
||||
* <listitem>GL_TRIANGLE_STRIP</listitem>
|
||||
* <listitem>GL_TRIANGLE_FAN</listitem>
|
||||
* <listitem>GL_TRIANGLES</listitem>
|
||||
* </itemizedlist>
|
||||
* (Note: only types available in GLES are listed)
|
||||
* @mode: A #CoglVerticesMode specifying how the vertices should be
|
||||
* interpreted.
|
||||
* @first: Specifies the index of the first vertex you want to draw with
|
||||
* @count: Specifies the number of vertices you want to draw.
|
||||
*
|
||||
|
@ -251,10 +280,10 @@ cogl_vertex_buffer_enable (CoglHandle handle,
|
|||
* drawing.
|
||||
*/
|
||||
void
|
||||
cogl_vertex_buffer_draw (CoglHandle handle,
|
||||
GLenum mode,
|
||||
GLint first,
|
||||
GLsizei count);
|
||||
cogl_vertex_buffer_draw (CoglHandle handle,
|
||||
CoglVerticesMode mode,
|
||||
int first,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* CoglIndicesType:
|
||||
|
@ -296,28 +325,19 @@ typedef enum _CoglIndicesType
|
|||
* the indices and reduce the demand for memory bandwidth.
|
||||
*/
|
||||
void
|
||||
cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
int id,
|
||||
unsigned int min_index,
|
||||
unsigned int max_index,
|
||||
CoglIndicesType indices_type,
|
||||
const void *indices_array,
|
||||
size_t indices_len);
|
||||
cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
int id,
|
||||
int min_index,
|
||||
int max_index,
|
||||
CoglIndicesType indices_type,
|
||||
const void *indices_array,
|
||||
int indices_len);
|
||||
|
||||
/**
|
||||
* cogl_vertex_buffer_draw_elements:
|
||||
* @handle: A vertex buffer handle
|
||||
* @mode: Specifies how the vertices should be interpreted, and should be
|
||||
* a valid GL primitive type:
|
||||
* <itemizedlist>
|
||||
* <listitem>GL_POINTS</listitem>
|
||||
* <listitem>GL_LINE_STRIP</listitem>
|
||||
* <listitem>GL_LINE_LOOP</listitem>
|
||||
* <listitem>GL_LINES</listitem>
|
||||
* <listitem>GL_TRIANGLE_STRIP</listitem>
|
||||
* <listitem>GL_TRIANGLE_FAN</listitem>
|
||||
* <listitem>GL_TRIANGLES</listitem>
|
||||
* </itemizedlist>
|
||||
* @mode: A #CoglVerticesMode specifying how the vertices should be
|
||||
* interpreted.
|
||||
* @indices_id: The identifier for a an array of indices previously added to
|
||||
* the given Cogl vertex buffer using
|
||||
* cogl_vertex_buffer_add_indices().
|
||||
|
@ -333,11 +353,11 @@ cogl_vertex_buffer_add_indices (CoglHandle handle,
|
|||
* drawing.
|
||||
*/
|
||||
void
|
||||
cogl_vertex_buffer_draw_elements (CoglHandle handle,
|
||||
GLenum mode,
|
||||
int indices_id,
|
||||
unsigned int indices_offset,
|
||||
unsigned int count);
|
||||
cogl_vertex_buffer_draw_elements (CoglHandle handle,
|
||||
CoglVerticesMode mode,
|
||||
int indices_id,
|
||||
int indices_offset,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* cogl_vertex_buffer_ref:
|
||||
|
|
|
@ -414,13 +414,13 @@ get_gl_type_size (CoglVertexBufferAttribFlags flags)
|
|||
}
|
||||
|
||||
void
|
||||
cogl_vertex_buffer_add (CoglHandle handle,
|
||||
const char *attribute_name,
|
||||
guint8 n_components,
|
||||
GLenum gl_type,
|
||||
gboolean normalized,
|
||||
guint16 stride,
|
||||
const void *pointer)
|
||||
cogl_vertex_buffer_add (CoglHandle handle,
|
||||
const char *attribute_name,
|
||||
guint8 n_components,
|
||||
CoglAttributeType type,
|
||||
gboolean normalized,
|
||||
guint16 stride,
|
||||
const void *pointer)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
GQuark name_quark = g_quark_from_string (attribute_name);
|
||||
|
@ -488,7 +488,7 @@ cogl_vertex_buffer_add (CoglHandle handle,
|
|||
attribute->u.pointer = pointer;
|
||||
attribute->texture_unit = texture_unit;
|
||||
|
||||
flags |= get_attribute_gl_type_flag_from_gl_type (gl_type);
|
||||
flags |= get_attribute_gl_type_flag_from_gl_type (type);
|
||||
flags |= COGL_VERTEX_BUFFER_ATTRIB_FLAG_ENABLED;
|
||||
|
||||
/* Note: We currently just assume, if an attribute is *ever* updated
|
||||
|
@ -1719,10 +1719,10 @@ disable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
|
|||
}
|
||||
|
||||
void
|
||||
cogl_vertex_buffer_draw (CoglHandle handle,
|
||||
GLenum mode,
|
||||
GLint first,
|
||||
GLsizei count)
|
||||
cogl_vertex_buffer_draw (CoglHandle handle,
|
||||
CoglVerticesMode mode,
|
||||
int first,
|
||||
int count)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
|
||||
|
@ -1772,13 +1772,13 @@ get_indices_type_size (GLuint indices_type)
|
|||
}
|
||||
|
||||
void
|
||||
cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
int id,
|
||||
unsigned int min_index,
|
||||
unsigned int max_index,
|
||||
CoglIndicesType indices_type,
|
||||
const void *indices_array,
|
||||
size_t indices_len)
|
||||
cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
int id,
|
||||
int min_index,
|
||||
int max_index,
|
||||
CoglIndicesType indices_type,
|
||||
const void *indices_array,
|
||||
int indices_len)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
GList *l;
|
||||
|
@ -1843,11 +1843,11 @@ cogl_vertex_buffer_add_indices (CoglHandle handle,
|
|||
}
|
||||
|
||||
void
|
||||
cogl_vertex_buffer_draw_elements (CoglHandle handle,
|
||||
GLenum mode,
|
||||
int indices_id,
|
||||
unsigned int indices_offset,
|
||||
unsigned int count)
|
||||
cogl_vertex_buffer_draw_elements (CoglHandle handle,
|
||||
CoglVerticesMode mode,
|
||||
int indices_id,
|
||||
int indices_offset,
|
||||
int count)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
gboolean fallback =
|
||||
|
|
Loading…
Reference in a new issue