[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
6bb6686666
commit
d51faed660
@ -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
|
||||
@ -159,7 +176,7 @@ void
|
||||
cogl_vertex_buffer_add (CoglHandle handle,
|
||||
const char *attribute_name,
|
||||
guint8 n_components,
|
||||
GLenum gl_type,
|
||||
CoglAttributeType type,
|
||||
gboolean normalized,
|
||||
guint16 stride,
|
||||
const void *pointer);
|
||||
@ -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.
|
||||
*
|
||||
@ -252,9 +281,9 @@ cogl_vertex_buffer_enable (CoglHandle handle,
|
||||
*/
|
||||
void
|
||||
cogl_vertex_buffer_draw (CoglHandle handle,
|
||||
GLenum mode,
|
||||
GLint first,
|
||||
GLsizei count);
|
||||
CoglVerticesMode mode,
|
||||
int first,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* CoglIndicesType:
|
||||
@ -298,26 +327,17 @@ typedef enum _CoglIndicesType
|
||||
void
|
||||
cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
int id,
|
||||
unsigned int min_index,
|
||||
unsigned int max_index,
|
||||
int min_index,
|
||||
int max_index,
|
||||
CoglIndicesType indices_type,
|
||||
const void *indices_array,
|
||||
size_t indices_len);
|
||||
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().
|
||||
@ -334,10 +354,10 @@ cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
*/
|
||||
void
|
||||
cogl_vertex_buffer_draw_elements (CoglHandle handle,
|
||||
GLenum mode,
|
||||
CoglVerticesMode mode,
|
||||
int indices_id,
|
||||
unsigned int indices_offset,
|
||||
unsigned int count);
|
||||
int indices_offset,
|
||||
int count);
|
||||
|
||||
/**
|
||||
* cogl_vertex_buffer_ref:
|
||||
|
@ -417,7 +417,7 @@ void
|
||||
cogl_vertex_buffer_add (CoglHandle handle,
|
||||
const char *attribute_name,
|
||||
guint8 n_components,
|
||||
GLenum gl_type,
|
||||
CoglAttributeType type,
|
||||
gboolean normalized,
|
||||
guint16 stride,
|
||||
const void *pointer)
|
||||
@ -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
|
||||
@ -1720,9 +1720,9 @@ disable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
|
||||
|
||||
void
|
||||
cogl_vertex_buffer_draw (CoglHandle handle,
|
||||
GLenum mode,
|
||||
GLint first,
|
||||
GLsizei count)
|
||||
CoglVerticesMode mode,
|
||||
int first,
|
||||
int count)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
|
||||
@ -1774,11 +1774,11 @@ 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,
|
||||
int min_index,
|
||||
int max_index,
|
||||
CoglIndicesType indices_type,
|
||||
const void *indices_array,
|
||||
size_t indices_len)
|
||||
int indices_len)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
GList *l;
|
||||
@ -1844,10 +1844,10 @@ cogl_vertex_buffer_add_indices (CoglHandle handle,
|
||||
|
||||
void
|
||||
cogl_vertex_buffer_draw_elements (CoglHandle handle,
|
||||
GLenum mode,
|
||||
CoglVerticesMode mode,
|
||||
int indices_id,
|
||||
unsigned int indices_offset,
|
||||
unsigned int count)
|
||||
int indices_offset,
|
||||
int count)
|
||||
{
|
||||
CoglVertexBuffer *buffer;
|
||||
gboolean fallback =
|
||||
|
@ -139,7 +139,7 @@ on_paint (ClutterActor *actor, TestState *state)
|
||||
{
|
||||
cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
|
||||
cogl_vertex_buffer_draw_elements (state->buffer,
|
||||
GL_TRIANGLE_STRIP,
|
||||
COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
||||
0, /* indices identifier */
|
||||
0, /* indices offset */
|
||||
state->n_static_indices);
|
||||
@ -287,7 +287,7 @@ init_quad_mesh (TestState *state)
|
||||
cogl_vertex_buffer_add (state->buffer,
|
||||
"gl_Vertex",
|
||||
3, /* n components */
|
||||
GL_FLOAT,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT,
|
||||
FALSE, /* normalized */
|
||||
0, /* stride */
|
||||
state->quad_mesh_verts);
|
||||
@ -295,7 +295,7 @@ init_quad_mesh (TestState *state)
|
||||
cogl_vertex_buffer_add (state->buffer,
|
||||
"gl_Color",
|
||||
4, /* n components */
|
||||
GL_UNSIGNED_BYTE,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
|
||||
FALSE, /* normalized */
|
||||
0, /* stride */
|
||||
state->quad_mesh_colors);
|
||||
|
Loading…
Reference in New Issue
Block a user