cogl: rename CoglVertexAttribute CoglAttribute
This is part of a broader cleanup of some of the experimental Cogl API. One of the reasons for this particular rename is to reduce the verbosity of using the API. Another reason is that CoglVertexArray is going to be renamed CoglAttributeBuffer and we want to help emphasize the relationship between CoglAttributes and CoglAttributeBuffers.
This commit is contained in:
parent
c4bafb48b6
commit
326c516304
@ -75,7 +75,7 @@ cogl_public_h = \
|
|||||||
$(srcdir)/cogl-index-array.h \
|
$(srcdir)/cogl-index-array.h \
|
||||||
$(srcdir)/cogl-vertex-array.h \
|
$(srcdir)/cogl-vertex-array.h \
|
||||||
$(srcdir)/cogl-indices.h \
|
$(srcdir)/cogl-indices.h \
|
||||||
$(srcdir)/cogl-vertex-attribute.h \
|
$(srcdir)/cogl-attribute.h \
|
||||||
$(srcdir)/cogl-primitive.h \
|
$(srcdir)/cogl-primitive.h \
|
||||||
$(srcdir)/cogl.h \
|
$(srcdir)/cogl.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
@ -201,8 +201,8 @@ cogl_sources_c = \
|
|||||||
$(srcdir)/cogl-vertex-array.c \
|
$(srcdir)/cogl-vertex-array.c \
|
||||||
$(srcdir)/cogl-indices-private.h \
|
$(srcdir)/cogl-indices-private.h \
|
||||||
$(srcdir)/cogl-indices.c \
|
$(srcdir)/cogl-indices.c \
|
||||||
$(srcdir)/cogl-vertex-attribute-private.h \
|
$(srcdir)/cogl-attribute-private.h \
|
||||||
$(srcdir)/cogl-vertex-attribute.c \
|
$(srcdir)/cogl-attribute.c \
|
||||||
$(srcdir)/cogl-primitive-private.h \
|
$(srcdir)/cogl-primitive-private.h \
|
||||||
$(srcdir)/cogl-primitive.c \
|
$(srcdir)/cogl-primitive.c \
|
||||||
$(srcdir)/cogl-matrix.c \
|
$(srcdir)/cogl-matrix.c \
|
||||||
|
@ -25,32 +25,32 @@
|
|||||||
* Robert Bragg <robert@linux.intel.com>
|
* Robert Bragg <robert@linux.intel.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __COGL_VERTEX_ATTRIBUTE_PRIVATE_H
|
#ifndef __COGL_ATTRIBUTE_PRIVATE_H
|
||||||
#define __COGL_VERTEX_ATTRIBUTE_PRIVATE_H
|
#define __COGL_ATTRIBUTE_PRIVATE_H
|
||||||
|
|
||||||
#include "cogl-object-private.h"
|
#include "cogl-object-private.h"
|
||||||
#include "cogl-vertex-attribute.h"
|
#include "cogl-attribute.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY,
|
COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY,
|
||||||
COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY,
|
COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY,
|
||||||
COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY,
|
COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY,
|
||||||
COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY,
|
COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY,
|
||||||
COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY
|
COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY
|
||||||
} CoglVertexAttributeNameID;
|
} CoglAttributeNameID;
|
||||||
|
|
||||||
struct _CoglVertexAttribute
|
struct _CoglAttribute
|
||||||
{
|
{
|
||||||
CoglObject _parent;
|
CoglObject _parent;
|
||||||
|
|
||||||
CoglVertexArray *array;
|
CoglVertexArray *array;
|
||||||
char *name;
|
char *name;
|
||||||
CoglVertexAttributeNameID name_id;
|
CoglAttributeNameID name_id;
|
||||||
gsize stride;
|
gsize stride;
|
||||||
gsize offset;
|
gsize offset;
|
||||||
int n_components;
|
int n_components;
|
||||||
CoglVertexAttributeType type;
|
CoglAttributeType type;
|
||||||
gboolean normalized;
|
gboolean normalized;
|
||||||
unsigned int texture_unit;
|
unsigned int texture_unit;
|
||||||
|
|
||||||
@ -75,29 +75,29 @@ typedef enum
|
|||||||
COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4
|
COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4
|
||||||
} CoglDrawFlags;
|
} CoglDrawFlags;
|
||||||
|
|
||||||
CoglVertexAttribute *
|
CoglAttribute *
|
||||||
_cogl_vertex_attribute_immutable_ref (CoglVertexAttribute *vertex_attribute);
|
_cogl_attribute_immutable_ref (CoglAttribute *attribute);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_vertex_attribute_immutable_unref (CoglVertexAttribute *vertex_attribute);
|
_cogl_attribute_immutable_unref (CoglAttribute *attribute);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
|
_cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes,
|
CoglAttribute **attributes,
|
||||||
CoglDrawFlags flags);
|
CoglDrawFlags flags);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode,
|
_cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglIndices *indices,
|
CoglIndices *indices,
|
||||||
CoglVertexAttribute **attributes,
|
CoglAttribute **attributes,
|
||||||
CoglDrawFlags flags);
|
CoglDrawFlags flags);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_vertex_attribute_disable_cached_arrays (void);
|
_cogl_attribute_disable_cached_arrays (void);
|
||||||
|
|
||||||
#endif /* __COGL_VERTEX_ATTRIBUTE_PRIVATE_H */
|
#endif /* __COGL_ATTRIBUTE_PRIVATE_H */
|
||||||
|
|
@ -32,8 +32,8 @@
|
|||||||
#include "cogl-context.h"
|
#include "cogl-context.h"
|
||||||
#include "cogl-object-private.h"
|
#include "cogl-object-private.h"
|
||||||
#include "cogl-journal-private.h"
|
#include "cogl-journal-private.h"
|
||||||
#include "cogl-vertex-attribute.h"
|
#include "cogl-attribute.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
#include "cogl-pipeline.h"
|
#include "cogl-pipeline.h"
|
||||||
#include "cogl-pipeline-private.h"
|
#include "cogl-pipeline-private.h"
|
||||||
#include "cogl-pipeline-opengl-private.h"
|
#include "cogl-pipeline-opengl-private.h"
|
||||||
@ -90,15 +90,15 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _cogl_vertex_attribute_free (CoglVertexAttribute *attribute);
|
static void _cogl_attribute_free (CoglAttribute *attribute);
|
||||||
|
|
||||||
COGL_OBJECT_DEFINE (VertexAttribute, vertex_attribute);
|
COGL_OBJECT_DEFINE (Attribute, attribute);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
gboolean
|
gboolean
|
||||||
validate_gl_attribute (const char *name,
|
validate_gl_attribute (const char *name,
|
||||||
int n_components,
|
int n_components,
|
||||||
CoglVertexAttributeNameID *name_id,
|
CoglAttributeNameID *name_id,
|
||||||
gboolean *normalized,
|
gboolean *normalized,
|
||||||
unsigned int *texture_unit)
|
unsigned int *texture_unit)
|
||||||
{
|
{
|
||||||
@ -116,7 +116,7 @@ validate_gl_attribute (const char *name,
|
|||||||
"attributes where n_components == 2, 3 or 4");
|
"attributes where n_components == 2, 3 or 4");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY;
|
||||||
}
|
}
|
||||||
else if (strcmp (name, "Color") == 0)
|
else if (strcmp (name, "Color") == 0)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ validate_gl_attribute (const char *name,
|
|||||||
"n_components == 3 or 4");
|
"n_components == 3 or 4");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY;
|
||||||
*normalized = TRUE;
|
*normalized = TRUE;
|
||||||
}
|
}
|
||||||
else if (strncmp (name, "MultiTexCoord", strlen ("MultiTexCoord")) == 0)
|
else if (strncmp (name, "MultiTexCoord", strlen ("MultiTexCoord")) == 0)
|
||||||
@ -138,7 +138,7 @@ validate_gl_attribute (const char *name,
|
|||||||
"texture unit number, E.g. gl_MultiTexCoord0\n");
|
"texture unit number, E.g. gl_MultiTexCoord0\n");
|
||||||
unit = 0;
|
unit = 0;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
||||||
}
|
}
|
||||||
else if (strncmp (name, "Normal") == 0)
|
else if (strncmp (name, "Normal") == 0)
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@ validate_gl_attribute (const char *name,
|
|||||||
"n_components == 3");
|
"n_components == 3");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY;
|
||||||
*normalized = TRUE;
|
*normalized = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -165,7 +165,7 @@ validate_gl_attribute (const char *name,
|
|||||||
gboolean
|
gboolean
|
||||||
validate_cogl_attribute (const char *name,
|
validate_cogl_attribute (const char *name,
|
||||||
int n_components,
|
int n_components,
|
||||||
CoglVertexAttributeNameID *name_id,
|
CoglAttributeNameID *name_id,
|
||||||
gboolean *normalized,
|
gboolean *normalized,
|
||||||
unsigned int *texture_unit)
|
unsigned int *texture_unit)
|
||||||
{
|
{
|
||||||
@ -183,7 +183,7 @@ validate_cogl_attribute (const char *name,
|
|||||||
"attributes where n_components == 2, 3 or 4");
|
"attributes where n_components == 2, 3 or 4");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY;
|
||||||
}
|
}
|
||||||
else if (strcmp (name, "color_in") == 0)
|
else if (strcmp (name, "color_in") == 0)
|
||||||
{
|
{
|
||||||
@ -194,10 +194,10 @@ validate_cogl_attribute (const char *name,
|
|||||||
"n_components == 3 or 4");
|
"n_components == 3 or 4");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY;
|
||||||
}
|
}
|
||||||
else if (strcmp (name, "tex_coord_in") == 0)
|
else if (strcmp (name, "tex_coord_in") == 0)
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
||||||
else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0)
|
else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0)
|
||||||
{
|
{
|
||||||
if (sscanf (name, "tex_coord%u_in", texture_unit) != 1)
|
if (sscanf (name, "tex_coord%u_in", texture_unit) != 1)
|
||||||
@ -207,7 +207,7 @@ validate_cogl_attribute (const char *name,
|
|||||||
"like \"cogl_tex_coord2_in\"\n");
|
"like \"cogl_tex_coord2_in\"\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
||||||
}
|
}
|
||||||
else if (strcmp (name, "normal_in") == 0)
|
else if (strcmp (name, "normal_in") == 0)
|
||||||
{
|
{
|
||||||
@ -218,7 +218,7 @@ validate_cogl_attribute (const char *name,
|
|||||||
"where n_components == 3");
|
"where n_components == 3");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY;
|
*name_id = COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY;
|
||||||
*normalized = TRUE;
|
*normalized = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -230,15 +230,15 @@ validate_cogl_attribute (const char *name,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglVertexAttribute *
|
CoglAttribute *
|
||||||
cogl_vertex_attribute_new (CoglVertexArray *array,
|
cogl_attribute_new (CoglVertexArray *array,
|
||||||
const char *name,
|
const char *name,
|
||||||
gsize stride,
|
gsize stride,
|
||||||
gsize offset,
|
gsize offset,
|
||||||
int n_components,
|
int n_components,
|
||||||
CoglVertexAttributeType type)
|
CoglAttributeType type)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute = g_slice_new (CoglVertexAttribute);
|
CoglAttribute *attribute = g_slice_new (CoglAttribute);
|
||||||
gboolean status;
|
gboolean status;
|
||||||
|
|
||||||
attribute->array = cogl_object_ref (array);
|
attribute->array = cogl_object_ref (array);
|
||||||
@ -265,7 +265,7 @@ cogl_vertex_attribute_new (CoglVertexArray *array,
|
|||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
attribute->name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY;
|
attribute->name_id = COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY;
|
||||||
attribute->normalized = FALSE;
|
attribute->normalized = FALSE;
|
||||||
attribute->texture_unit = 0;
|
attribute->texture_unit = 0;
|
||||||
status = TRUE;
|
status = TRUE;
|
||||||
@ -273,17 +273,17 @@ cogl_vertex_attribute_new (CoglVertexArray *array,
|
|||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
_cogl_vertex_attribute_free (attribute);
|
_cogl_attribute_free (attribute);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cogl_vertex_attribute_object_new (attribute);
|
return _cogl_attribute_object_new (attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_vertex_attribute_get_normalized (CoglVertexAttribute *attribute)
|
cogl_attribute_get_normalized (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_vertex_attribute (attribute), FALSE);
|
g_return_val_if_fail (cogl_is_attribute (attribute), FALSE);
|
||||||
|
|
||||||
return attribute->normalized;
|
return attribute->normalized;
|
||||||
}
|
}
|
||||||
@ -301,10 +301,10 @@ warn_about_midscene_changes (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_vertex_attribute_set_normalized (CoglVertexAttribute *attribute,
|
cogl_attribute_set_normalized (CoglAttribute *attribute,
|
||||||
gboolean normalized)
|
gboolean normalized)
|
||||||
{
|
{
|
||||||
g_return_if_fail (cogl_is_vertex_attribute (attribute));
|
g_return_if_fail (cogl_is_attribute (attribute));
|
||||||
|
|
||||||
if (G_UNLIKELY (attribute->immutable_ref))
|
if (G_UNLIKELY (attribute->immutable_ref))
|
||||||
warn_about_midscene_changes ();
|
warn_about_midscene_changes ();
|
||||||
@ -313,18 +313,18 @@ cogl_vertex_attribute_set_normalized (CoglVertexAttribute *attribute,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglVertexArray *
|
CoglVertexArray *
|
||||||
cogl_vertex_attribute_get_array (CoglVertexAttribute *attribute)
|
cogl_attribute_get_array (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_vertex_attribute (attribute), NULL);
|
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
|
||||||
|
|
||||||
return attribute->array;
|
return attribute->array;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_vertex_attribute_set_array (CoglVertexAttribute *attribute,
|
cogl_attribute_set_array (CoglAttribute *attribute,
|
||||||
CoglVertexArray *array)
|
CoglVertexArray *array)
|
||||||
{
|
{
|
||||||
g_return_if_fail (cogl_is_vertex_attribute (attribute));
|
g_return_if_fail (cogl_is_attribute (attribute));
|
||||||
|
|
||||||
if (G_UNLIKELY (attribute->immutable_ref))
|
if (G_UNLIKELY (attribute->immutable_ref))
|
||||||
warn_about_midscene_changes ();
|
warn_about_midscene_changes ();
|
||||||
@ -335,33 +335,33 @@ cogl_vertex_attribute_set_array (CoglVertexAttribute *attribute,
|
|||||||
attribute->array = array;
|
attribute->array = array;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglVertexAttribute *
|
CoglAttribute *
|
||||||
_cogl_vertex_attribute_immutable_ref (CoglVertexAttribute *vertex_attribute)
|
_cogl_attribute_immutable_ref (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (cogl_is_vertex_attribute (vertex_attribute), NULL);
|
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
|
||||||
|
|
||||||
vertex_attribute->immutable_ref++;
|
attribute->immutable_ref++;
|
||||||
_cogl_buffer_immutable_ref (COGL_BUFFER (vertex_attribute->array));
|
_cogl_buffer_immutable_ref (COGL_BUFFER (attribute->array));
|
||||||
return vertex_attribute;
|
return attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_vertex_attribute_immutable_unref (CoglVertexAttribute *vertex_attribute)
|
_cogl_attribute_immutable_unref (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
g_return_if_fail (cogl_is_vertex_attribute (vertex_attribute));
|
g_return_if_fail (cogl_is_attribute (attribute));
|
||||||
g_return_if_fail (vertex_attribute->immutable_ref > 0);
|
g_return_if_fail (attribute->immutable_ref > 0);
|
||||||
|
|
||||||
vertex_attribute->immutable_ref--;
|
attribute->immutable_ref--;
|
||||||
_cogl_buffer_immutable_unref (COGL_BUFFER (vertex_attribute->array));
|
_cogl_buffer_immutable_unref (COGL_BUFFER (attribute->array));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_vertex_attribute_free (CoglVertexAttribute *attribute)
|
_cogl_attribute_free (CoglAttribute *attribute)
|
||||||
{
|
{
|
||||||
g_free (attribute->name);
|
g_free (attribute->name);
|
||||||
cogl_object_unref (attribute->array);
|
cogl_object_unref (attribute->array);
|
||||||
|
|
||||||
g_slice_free (CoglVertexAttribute, attribute);
|
g_slice_free (CoglAttribute, attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -477,7 +477,7 @@ set_enabled_arrays (CoglBitmask *value_cache,
|
|||||||
|
|
||||||
static CoglHandle
|
static CoglHandle
|
||||||
enable_gl_state (CoglDrawFlags flags,
|
enable_gl_state (CoglDrawFlags flags,
|
||||||
CoglVertexAttribute **attributes,
|
CoglAttribute **attributes,
|
||||||
ValidateLayerState *state)
|
ValidateLayerState *state)
|
||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
||||||
@ -507,7 +507,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
for (i = 0; attributes[i]; i++)
|
for (i = 0; attributes[i]; i++)
|
||||||
switch (attributes[i]->name_id)
|
switch (attributes[i]->name_id)
|
||||||
{
|
{
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
||||||
if ((flags & COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE) == 0 &&
|
if ((flags & COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE) == 0 &&
|
||||||
!_cogl_pipeline_get_real_blend_enabled (source))
|
!_cogl_pipeline_get_real_blend_enabled (source))
|
||||||
{
|
{
|
||||||
@ -520,7 +520,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
skip_gl_color = TRUE;
|
skip_gl_color = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
||||||
n_tex_coord_attribs++;
|
n_tex_coord_attribs++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
|
|
||||||
for (i = 0; attributes[i]; i++)
|
for (i = 0; attributes[i]; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute = attributes[i];
|
CoglAttribute *attribute = attributes[i];
|
||||||
CoglVertexArray *vertex_array;
|
CoglVertexArray *vertex_array;
|
||||||
CoglBuffer *buffer;
|
CoglBuffer *buffer;
|
||||||
void *base;
|
void *base;
|
||||||
@ -605,13 +605,13 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
int attrib_location;
|
int attrib_location;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vertex_array = cogl_vertex_attribute_get_array (attribute);
|
vertex_array = cogl_attribute_get_array (attribute);
|
||||||
buffer = COGL_BUFFER (vertex_array);
|
buffer = COGL_BUFFER (vertex_array);
|
||||||
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY);
|
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY);
|
||||||
|
|
||||||
switch (attribute->name_id)
|
switch (attribute->name_id)
|
||||||
{
|
{
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
attrib_location =
|
attrib_location =
|
||||||
@ -640,7 +640,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
attrib_location =
|
attrib_location =
|
||||||
@ -667,7 +667,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
attrib_location = _cogl_pipeline_progend_glsl_get_tex_coord_attribute
|
attrib_location = _cogl_pipeline_progend_glsl_get_tex_coord_attribute
|
||||||
@ -695,7 +695,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
attrib_location =
|
attrib_location =
|
||||||
@ -722,7 +722,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
||||||
{
|
{
|
||||||
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
||||||
/* FIXME: go through cogl cache to enable generic array. */
|
/* FIXME: go through cogl cache to enable generic array. */
|
||||||
@ -755,7 +755,7 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_vertex_attribute_disable_cached_arrays (void)
|
_cogl_attribute_disable_cached_arrays (void)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ _cogl_vertex_attribute_disable_cached_arrays (void)
|
|||||||
/* FIXME: we shouldn't be disabling state after drawing we should
|
/* FIXME: we shouldn't be disabling state after drawing we should
|
||||||
* just disable the things not needed after enabling state. */
|
* just disable the things not needed after enabling state. */
|
||||||
static void
|
static void
|
||||||
disable_gl_state (CoglVertexAttribute **attributes,
|
disable_gl_state (CoglAttribute **attributes,
|
||||||
CoglPipeline *source)
|
CoglPipeline *source)
|
||||||
{
|
{
|
||||||
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
||||||
@ -781,30 +781,30 @@ disable_gl_state (CoglVertexAttribute **attributes,
|
|||||||
|
|
||||||
for (i = 0; attributes[i]; i++)
|
for (i = 0; attributes[i]; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute = attributes[i];
|
CoglAttribute *attribute = attributes[i];
|
||||||
|
|
||||||
switch (attribute->name_id)
|
switch (attribute->name_id)
|
||||||
{
|
{
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
||||||
/* GE (glDisableClientState (GL_COLOR_ARRAY)); */
|
/* GE (glDisableClientState (GL_COLOR_ARRAY)); */
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
||||||
/* FIXME: go through cogl cache to enable normal array */
|
/* FIXME: go through cogl cache to enable normal array */
|
||||||
#ifndef HAVE_COGL_GLES2
|
#ifndef HAVE_COGL_GLES2
|
||||||
GE (glDisableClientState (GL_NORMAL_ARRAY));
|
GE (glDisableClientState (GL_NORMAL_ARRAY));
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
||||||
/* The enabled state of the texture coord arrays is
|
/* The enabled state of the texture coord arrays is
|
||||||
cached in ctx->enabled_texcoord_arrays so we don't
|
cached in ctx->enabled_texcoord_arrays so we don't
|
||||||
need to do anything here. The array will be disabled
|
need to do anything here. The array will be disabled
|
||||||
by the next drawing primitive if it is not
|
by the next drawing primitive if it is not
|
||||||
required */
|
required */
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
||||||
/* GE (glDisableClientState (GL_VERTEX_ARRAY)); */
|
/* GE (glDisableClientState (GL_VERTEX_ARRAY)); */
|
||||||
break;
|
break;
|
||||||
case COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
||||||
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
||||||
/* FIXME: go through cogl cache to enable generic array */
|
/* FIXME: go through cogl cache to enable generic array */
|
||||||
GE (glDisableVertexAttribArray (generic_index++));
|
GE (glDisableVertexAttribArray (generic_index++));
|
||||||
@ -842,7 +842,7 @@ static void
|
|||||||
add_line (void *vertices,
|
add_line (void *vertices,
|
||||||
void *indices,
|
void *indices,
|
||||||
CoglIndicesType indices_type,
|
CoglIndicesType indices_type,
|
||||||
CoglVertexAttribute *attribute,
|
CoglAttribute *attribute,
|
||||||
int start,
|
int start,
|
||||||
int end,
|
int end,
|
||||||
CoglVertexP3 *lines,
|
CoglVertexP3 *lines,
|
||||||
@ -869,13 +869,13 @@ add_line (void *vertices,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglVertexP3 *
|
static CoglVertexP3 *
|
||||||
get_wire_lines (CoglVertexAttribute *attribute,
|
get_wire_lines (CoglAttribute *attribute,
|
||||||
CoglVerticesMode mode,
|
CoglVerticesMode mode,
|
||||||
int n_vertices_in,
|
int n_vertices_in,
|
||||||
int *n_vertices_out,
|
int *n_vertices_out,
|
||||||
CoglIndices *_indices)
|
CoglIndices *_indices)
|
||||||
{
|
{
|
||||||
CoglVertexArray *vertex_array = cogl_vertex_attribute_get_array (attribute);
|
CoglVertexArray *vertex_array = cogl_attribute_get_array (attribute);
|
||||||
void *vertices;
|
void *vertices;
|
||||||
CoglIndexArray *index_array;
|
CoglIndexArray *index_array;
|
||||||
void *indices;
|
void *indices;
|
||||||
@ -988,14 +988,14 @@ static void
|
|||||||
draw_wireframe (CoglVerticesMode mode,
|
draw_wireframe (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes,
|
CoglAttribute **attributes,
|
||||||
CoglIndices *indices)
|
CoglIndices *indices)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *position = NULL;
|
CoglAttribute *position = NULL;
|
||||||
int i;
|
int i;
|
||||||
int n_line_vertices;
|
int n_line_vertices;
|
||||||
static CoglPipeline *wire_pipeline;
|
static CoglPipeline *wire_pipeline;
|
||||||
CoglVertexAttribute *wire_attribute[2];
|
CoglAttribute *wire_attribute[2];
|
||||||
CoglVertexP3 *lines;
|
CoglVertexP3 *lines;
|
||||||
CoglVertexArray *array;
|
CoglVertexArray *array;
|
||||||
|
|
||||||
@ -1018,11 +1018,11 @@ draw_wireframe (CoglVerticesMode mode,
|
|||||||
array = cogl_vertex_array_new (sizeof (CoglVertexP3) * n_line_vertices,
|
array = cogl_vertex_array_new (sizeof (CoglVertexP3) * n_line_vertices,
|
||||||
lines);
|
lines);
|
||||||
wire_attribute[0] =
|
wire_attribute[0] =
|
||||||
cogl_vertex_attribute_new (array, "cogl_position_in",
|
cogl_attribute_new (array, "cogl_position_in",
|
||||||
sizeof (CoglVertexP3),
|
sizeof (CoglVertexP3),
|
||||||
0,
|
0,
|
||||||
3,
|
3,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
wire_attribute[1] = NULL;
|
wire_attribute[1] = NULL;
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
|
|
||||||
@ -1037,7 +1037,7 @@ draw_wireframe (CoglVerticesMode mode,
|
|||||||
|
|
||||||
/* temporarily disable the wireframe to avoid recursion! */
|
/* temporarily disable the wireframe to avoid recursion! */
|
||||||
cogl_debug_flags &= ~COGL_DEBUG_WIREFRAME;
|
cogl_debug_flags &= ~COGL_DEBUG_WIREFRAME;
|
||||||
_cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_LINES,
|
_cogl_draw_attributes_array (COGL_VERTICES_MODE_LINES,
|
||||||
0,
|
0,
|
||||||
n_line_vertices,
|
n_line_vertices,
|
||||||
wire_attribute,
|
wire_attribute,
|
||||||
@ -1087,10 +1087,10 @@ flush_state (CoglDrawFlags flags,
|
|||||||
* skipping the implicit journal flush, the framebuffer flush and
|
* skipping the implicit journal flush, the framebuffer flush and
|
||||||
* pipeline validation. */
|
* pipeline validation. */
|
||||||
void
|
void
|
||||||
_cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
|
_cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes,
|
CoglAttribute **attributes,
|
||||||
CoglDrawFlags flags)
|
CoglDrawFlags flags)
|
||||||
{
|
{
|
||||||
ValidateLayerState state;
|
ValidateLayerState state;
|
||||||
@ -1113,42 +1113,42 @@ _cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
|
cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes)
|
CoglAttribute **attributes)
|
||||||
{
|
{
|
||||||
_cogl_draw_vertex_attributes_array (mode, first_vertex,
|
_cogl_draw_attributes_array (mode, first_vertex,
|
||||||
n_vertices, attributes,
|
n_vertices, attributes,
|
||||||
0 /* no flags */);
|
0 /* no flags */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_vertex_attributes (CoglVerticesMode mode,
|
cogl_draw_attributes (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int n_attributes;
|
int n_attributes;
|
||||||
CoglVertexAttribute *attribute;
|
CoglAttribute *attribute;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
va_start (ap, n_vertices);
|
va_start (ap, n_vertices);
|
||||||
for (n_attributes = 0; va_arg (ap, CoglVertexAttribute *); n_attributes++)
|
for (n_attributes = 0; va_arg (ap, CoglAttribute *); n_attributes++)
|
||||||
;
|
;
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1));
|
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
|
||||||
attributes[n_attributes] = NULL;
|
attributes[n_attributes] = NULL;
|
||||||
|
|
||||||
va_start (ap, n_vertices);
|
va_start (ap, n_vertices);
|
||||||
for (i = 0; (attribute = va_arg (ap, CoglVertexAttribute *)); i++)
|
for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++)
|
||||||
attributes[i] = attribute;
|
attributes[i] = attribute;
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
cogl_draw_vertex_attributes_array (mode, first_vertex, n_vertices,
|
cogl_draw_attributes_array (mode, first_vertex, n_vertices,
|
||||||
attributes);
|
attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,11 +1168,11 @@ sizeof_index_type (CoglIndicesType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode,
|
_cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglIndices *indices,
|
CoglIndices *indices,
|
||||||
CoglVertexAttribute **attributes,
|
CoglAttribute **attributes,
|
||||||
CoglDrawFlags flags)
|
CoglDrawFlags flags)
|
||||||
{
|
{
|
||||||
ValidateLayerState state;
|
ValidateLayerState state;
|
||||||
@ -1225,19 +1225,19 @@ _cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode,
|
cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglIndices *indices,
|
CoglIndices *indices,
|
||||||
CoglVertexAttribute **attributes)
|
CoglAttribute **attributes)
|
||||||
{
|
{
|
||||||
_cogl_draw_indexed_vertex_attributes_array (mode, first_vertex,
|
_cogl_draw_indexed_attributes_array (mode, first_vertex,
|
||||||
n_vertices, indices, attributes,
|
n_vertices, indices, attributes,
|
||||||
0 /* no flags */);
|
0 /* no flags */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_indexed_vertex_attributes (CoglVerticesMode mode,
|
cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglIndices *indices,
|
CoglIndices *indices,
|
||||||
@ -1245,24 +1245,24 @@ cogl_draw_indexed_vertex_attributes (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int n_attributes;
|
int n_attributes;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
int i;
|
int i;
|
||||||
CoglVertexAttribute *attribute;
|
CoglAttribute *attribute;
|
||||||
|
|
||||||
va_start (ap, indices);
|
va_start (ap, indices);
|
||||||
for (n_attributes = 0; va_arg (ap, CoglVertexAttribute *); n_attributes++)
|
for (n_attributes = 0; va_arg (ap, CoglAttribute *); n_attributes++)
|
||||||
;
|
;
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1));
|
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
|
||||||
attributes[n_attributes] = NULL;
|
attributes[n_attributes] = NULL;
|
||||||
|
|
||||||
va_start (ap, indices);
|
va_start (ap, indices);
|
||||||
for (i = 0; (attribute = va_arg (ap, CoglVertexAttribute *)); i++)
|
for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++)
|
||||||
attributes[i] = attribute;
|
attributes[i] = attribute;
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
cogl_draw_indexed_vertex_attributes_array (mode,
|
cogl_draw_indexed_attributes_array (mode,
|
||||||
first_vertex,
|
first_vertex,
|
||||||
n_vertices,
|
n_vertices,
|
||||||
indices,
|
indices,
|
@ -28,8 +28,8 @@
|
|||||||
#error "Only <cogl/cogl.h> can be included directly."
|
#error "Only <cogl/cogl.h> can be included directly."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __COGL_VERTEX_ATTRIBUTE_H__
|
#ifndef __COGL_ATTRIBUTE_H__
|
||||||
#define __COGL_VERTEX_ATTRIBUTE_H__
|
#define __COGL_ATTRIBUTE_H__
|
||||||
|
|
||||||
#include <cogl/cogl-vertex-array.h>
|
#include <cogl/cogl-vertex-array.h>
|
||||||
#include <cogl/cogl-indices.h>
|
#include <cogl/cogl-indices.h>
|
||||||
@ -37,40 +37,17 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:cogl-vertex-attribute
|
* SECTION:cogl-attribute
|
||||||
* @short_description: Fuctions for declaring and drawing vertex
|
* @short_description: Functions for declaring and drawing vertex
|
||||||
* attributes
|
* attributes
|
||||||
*
|
*
|
||||||
* FIXME
|
* FIXME
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _CoglVertexAttribute CoglVertexAttribute;
|
typedef struct _CoglAttribute CoglAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglVertexAttributeType:
|
* cogl_attribute_new:
|
||||||
* @COGL_VERTEX_ATTRIBUTE_TYPE_BYTE: Data is the same size of a byte
|
|
||||||
* @COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE: Data is the same size of an
|
|
||||||
* unsigned byte
|
|
||||||
* @COGL_VERTEX_ATTRIBUTE_TYPE_SHORT: Data is the same size of a short integer
|
|
||||||
* @COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_SHORT: Data is the same size of
|
|
||||||
* an unsigned short integer
|
|
||||||
* @COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT: Data is the same size of a float
|
|
||||||
*
|
|
||||||
* Data types for the components of a vertex attribute.
|
|
||||||
*
|
|
||||||
* Since: 1.4
|
|
||||||
* Stability: Unstable
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_BYTE = 0x1400,
|
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE = 0x1401,
|
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_SHORT = 0x1402,
|
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_SHORT = 0x1403,
|
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT = 0x1406
|
|
||||||
} CoglVertexAttributeType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cogl_vertex_attribute_new:
|
|
||||||
* @array: The #CoglVertexArray containing the actual attribute data
|
* @array: The #CoglVertexArray containing the actual attribute data
|
||||||
* @name: The name of the attribute (used to reference it from GLSL)
|
* @name: The name of the attribute (used to reference it from GLSL)
|
||||||
* @stride: The number of bytes to jump to get to the next attribute
|
* @stride: The number of bytes to jump to get to the next attribute
|
||||||
@ -145,7 +122,7 @@ typedef enum {
|
|||||||
* mapped into the GPU which can be a bottlneck when dealing with
|
* mapped into the GPU which can be a bottlneck when dealing with
|
||||||
* a large number of vertices.
|
* a large number of vertices.
|
||||||
*
|
*
|
||||||
* Returns: A newly allocated #CoglVertexAttribute describing the
|
* Returns: A newly allocated #CoglAttribute describing the
|
||||||
* layout for a list of attribute values stored in @array.
|
* layout for a list of attribute values stored in @array.
|
||||||
*
|
*
|
||||||
* Since: 1.4
|
* Since: 1.4
|
||||||
@ -153,53 +130,53 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
/* XXX: look for a precedent to see if the stride/offset args should
|
/* XXX: look for a precedent to see if the stride/offset args should
|
||||||
* have a different order. */
|
* have a different order. */
|
||||||
CoglVertexAttribute *
|
CoglAttribute *
|
||||||
cogl_vertex_attribute_new (CoglVertexArray *array,
|
cogl_attribute_new (CoglVertexArray *array,
|
||||||
const char *name,
|
const char *name,
|
||||||
gsize stride,
|
gsize stride,
|
||||||
gsize offset,
|
gsize offset,
|
||||||
int components,
|
int components,
|
||||||
CoglVertexAttributeType type);
|
CoglAttributeType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_is_vertex_attribute:
|
* cogl_is_attribute:
|
||||||
* @object: A #CoglObject
|
* @object: A #CoglObject
|
||||||
*
|
*
|
||||||
* Gets whether the given object references a #CoglVertexAttribute.
|
* Gets whether the given object references a #CoglAttribute.
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if the handle references a #CoglVertexAttribute,
|
* Return value: %TRUE if the handle references a #CoglAttribute,
|
||||||
* %FALSE otherwise
|
* %FALSE otherwise
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_is_vertex_attribute (void *object);
|
cogl_is_attribute (void *object);
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_vertex_attributes (CoglVerticesMode mode,
|
cogl_draw_attributes (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
...) G_GNUC_NULL_TERMINATED;
|
...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_vertex_attributes_array (CoglVerticesMode mode,
|
cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes);
|
CoglAttribute **attributes);
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_indexed_vertex_attributes (CoglVerticesMode mode,
|
cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglIndices *indices,
|
CoglIndices *indices,
|
||||||
...) G_GNUC_NULL_TERMINATED;
|
...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode,
|
cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||||
int first_vertex,
|
int first_vertex,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglIndices *indices,
|
CoglIndices *indices,
|
||||||
CoglVertexAttribute **attributes);
|
CoglAttribute **attributes);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_VERTEX_ATTRIBUTE_H__ */
|
#endif /* __COGL_ATTRIBUTE_H__ */
|
||||||
|
|
@ -167,7 +167,7 @@ cogl_create_context (void)
|
|||||||
_context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE;
|
_context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
_context->journal_flush_attributes_array =
|
_context->journal_flush_attributes_array =
|
||||||
g_array_new (TRUE, FALSE, sizeof (CoglVertexAttribute *));
|
g_array_new (TRUE, FALSE, sizeof (CoglAttribute *));
|
||||||
_context->journal_clip_bounds = NULL;
|
_context->journal_clip_bounds = NULL;
|
||||||
|
|
||||||
_context->polygon_vertices = g_array_new (FALSE, FALSE, sizeof (float));
|
_context->polygon_vertices = g_array_new (FALSE, FALSE, sizeof (float));
|
||||||
|
@ -89,7 +89,7 @@ cogl_index_array_allocate (CoglIndexArray *indices,
|
|||||||
* data.
|
* data.
|
||||||
*
|
*
|
||||||
* XXX: I think in the end it'll be that CoglIndices are to
|
* XXX: I think in the end it'll be that CoglIndices are to
|
||||||
* CoglIndexArrays as CoglVertexAttributes are to CoglVertices. I.e
|
* CoglIndexArrays as CoglAttributes are to CoglVertices. I.e
|
||||||
* a CoglIndexArray is a lite subclass of CoglBuffer that simply
|
* a CoglIndexArray is a lite subclass of CoglBuffer that simply
|
||||||
* implies that the buffer will later be bound as indices but doesn't
|
* implies that the buffer will later be bound as indices but doesn't
|
||||||
* track more detailed meta data. CoglIndices build on a
|
* track more detailed meta data. CoglIndices build on a
|
||||||
@ -98,7 +98,7 @@ cogl_index_array_allocate (CoglIndexArray *indices,
|
|||||||
*
|
*
|
||||||
* XXX: The double plurel form that "Indices" "Array" implies could be
|
* XXX: The double plurel form that "Indices" "Array" implies could be
|
||||||
* a bit confusing. Also to be a bit more consistent with
|
* a bit confusing. Also to be a bit more consistent with
|
||||||
* CoglVertexArray vs CoglVertexAttribute it might be best to rename so
|
* CoglVertexArray vs CoglAttribute it might be best to rename so
|
||||||
* we have CoglIndexArray vs CoglIndices? maybe even
|
* we have CoglIndexArray vs CoglIndices? maybe even
|
||||||
* CoglIndexRange :-/ ?
|
* CoglIndexRange :-/ ?
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "cogl-vertex-buffer-private.h"
|
#include "cogl-vertex-buffer-private.h"
|
||||||
#include "cogl-framebuffer-private.h"
|
#include "cogl-framebuffer-private.h"
|
||||||
#include "cogl-profile.h"
|
#include "cogl-profile.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
#include "cogl-point-in-poly-private.h"
|
#include "cogl-point-in-poly-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -260,7 +260,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
CoglJournalFlushState *state = data;
|
CoglJournalFlushState *state = data;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
|
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
|
||||||
@ -287,7 +287,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
COGL_MATRIX_MODELVIEW);
|
COGL_MATRIX_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes = (CoglVertexAttribute **)state->attributes->data;
|
attributes = (CoglAttribute **)state->attributes->data;
|
||||||
cogl_push_source (state->source);
|
cogl_push_source (state->source);
|
||||||
|
|
||||||
if (!_cogl_pipeline_get_real_blend_enabled (state->source))
|
if (!_cogl_pipeline_get_real_blend_enabled (state->source))
|
||||||
@ -296,7 +296,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
#ifdef HAVE_COGL_GL
|
#ifdef HAVE_COGL_GL
|
||||||
|
|
||||||
/* XXX: it's rather evil that we sneak in the GL_QUADS enum here... */
|
/* XXX: it's rather evil that we sneak in the GL_QUADS enum here... */
|
||||||
_cogl_draw_vertex_attributes_array (GL_QUADS,
|
_cogl_draw_attributes_array (GL_QUADS,
|
||||||
state->current_vertex, batch_len * 4,
|
state->current_vertex, batch_len * 4,
|
||||||
attributes,
|
attributes,
|
||||||
draw_flags);
|
draw_flags);
|
||||||
@ -304,7 +304,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
#else /* HAVE_COGL_GL */
|
#else /* HAVE_COGL_GL */
|
||||||
if (batch_len > 1)
|
if (batch_len > 1)
|
||||||
{
|
{
|
||||||
_cogl_draw_indexed_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLES,
|
_cogl_draw_indexed_attributes_array (COGL_VERTICES_MODE_TRIANGLES,
|
||||||
state->current_vertex * 6 / 4,
|
state->current_vertex * 6 / 4,
|
||||||
batch_len * 6,
|
batch_len * 6,
|
||||||
state->indices,
|
state->indices,
|
||||||
@ -314,7 +314,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
_cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
||||||
state->current_vertex, 4,
|
state->current_vertex, 4,
|
||||||
attributes,
|
attributes,
|
||||||
draw_flags);
|
draw_flags);
|
||||||
@ -332,7 +332,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
static CoglPipeline *outline = NULL;
|
static CoglPipeline *outline = NULL;
|
||||||
guint8 color_intensity;
|
guint8 color_intensity;
|
||||||
int i;
|
int i;
|
||||||
CoglVertexAttribute *loop_attributes[2];
|
CoglAttribute *loop_attributes[2];
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
|||||||
loop_attributes[0] = attributes[0]; /* we just want the position */
|
loop_attributes[0] = attributes[0]; /* we just want the position */
|
||||||
loop_attributes[1] = NULL;
|
loop_attributes[1] = NULL;
|
||||||
for (i = 0; i < batch_len; i++)
|
for (i = 0; i < batch_len; i++)
|
||||||
_cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_LINE_LOOP,
|
_cogl_draw_attributes_array (COGL_VERTICES_MODE_LINE_LOOP,
|
||||||
4 * i + state->current_vertex, 4,
|
4 * i + state->current_vertex, 4,
|
||||||
loop_attributes,
|
loop_attributes,
|
||||||
draw_flags);
|
draw_flags);
|
||||||
@ -483,15 +483,14 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries (
|
|||||||
/* NB: attributes 0 and 1 are position and color */
|
/* NB: attributes 0 and 1 are position and color */
|
||||||
|
|
||||||
for (i = 2; i < state->attributes->len; i++)
|
for (i = 2; i < state->attributes->len; i++)
|
||||||
cogl_object_unref (g_array_index (state->attributes,
|
cogl_object_unref (g_array_index (state->attributes, CoglAttribute *, i));
|
||||||
CoglVertexAttribute *, i));
|
|
||||||
|
|
||||||
g_array_set_size (state->attributes, batch_start->n_layers + 2);
|
g_array_set_size (state->attributes, batch_start->n_layers + 2);
|
||||||
|
|
||||||
for (i = 0; i < batch_start->n_layers; i++)
|
for (i = 0; i < batch_start->n_layers; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute **attribute_entry =
|
CoglAttribute **attribute_entry =
|
||||||
&g_array_index (state->attributes, CoglVertexAttribute *, i + 2);
|
&g_array_index (state->attributes, CoglAttribute *, i + 2);
|
||||||
const char *names[] = {
|
const char *names[] = {
|
||||||
"cogl_tex_coord0_in",
|
"cogl_tex_coord0_in",
|
||||||
"cogl_tex_coord1_in",
|
"cogl_tex_coord1_in",
|
||||||
@ -519,14 +518,14 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries (
|
|||||||
/* XXX: it may be worth having some form of static initializer for
|
/* XXX: it may be worth having some form of static initializer for
|
||||||
* attributes... */
|
* attributes... */
|
||||||
*attribute_entry =
|
*attribute_entry =
|
||||||
cogl_vertex_attribute_new (state->vertex_array,
|
cogl_attribute_new (state->vertex_array,
|
||||||
name,
|
name,
|
||||||
state->stride,
|
state->stride,
|
||||||
state->array_offset +
|
state->array_offset +
|
||||||
(POS_STRIDE + COLOR_STRIDE) * 4 +
|
(POS_STRIDE + COLOR_STRIDE) * 4 +
|
||||||
TEX_STRIDE * 4 * i,
|
TEX_STRIDE * 4 * i,
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
|
|
||||||
if (i >= 8)
|
if (i >= 8)
|
||||||
g_free (name);
|
g_free (name);
|
||||||
@ -559,7 +558,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
|
|||||||
CoglJournalFlushState *state = data;
|
CoglJournalFlushState *state = data;
|
||||||
gsize stride;
|
gsize stride;
|
||||||
int i;
|
int i;
|
||||||
CoglVertexAttribute **attribute_entry;
|
CoglAttribute **attribute_entry;
|
||||||
COGL_STATIC_TIMER (time_flush_vbo_texcoord_pipeline_entries,
|
COGL_STATIC_TIMER (time_flush_vbo_texcoord_pipeline_entries,
|
||||||
"flush: clip+vbo+texcoords+pipeline+entries", /* parent */
|
"flush: clip+vbo+texcoords+pipeline+entries", /* parent */
|
||||||
"flush: vbo+texcoords+pipeline+entries",
|
"flush: vbo+texcoords+pipeline+entries",
|
||||||
@ -589,39 +588,36 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
|
|||||||
state->stride = stride;
|
state->stride = stride;
|
||||||
|
|
||||||
for (i = 0; i < state->attributes->len; i++)
|
for (i = 0; i < state->attributes->len; i++)
|
||||||
cogl_object_unref (g_array_index (state->attributes,
|
cogl_object_unref (g_array_index (state->attributes, CoglAttribute *, i));
|
||||||
CoglVertexAttribute *, i));
|
|
||||||
|
|
||||||
g_array_set_size (state->attributes, 2);
|
g_array_set_size (state->attributes, 2);
|
||||||
|
|
||||||
attribute_entry =
|
attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 0);
|
||||||
&g_array_index (state->attributes, CoglVertexAttribute *, 0);
|
*attribute_entry = cogl_attribute_new (state->vertex_array,
|
||||||
*attribute_entry =
|
|
||||||
cogl_vertex_attribute_new (state->vertex_array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
stride,
|
stride,
|
||||||
state->array_offset,
|
state->array_offset,
|
||||||
N_POS_COMPONENTS,
|
N_POS_COMPONENTS,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
|
|
||||||
attribute_entry =
|
attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 1);
|
||||||
&g_array_index (state->attributes, CoglVertexAttribute *, 1);
|
|
||||||
*attribute_entry =
|
*attribute_entry =
|
||||||
cogl_vertex_attribute_new (state->vertex_array,
|
cogl_attribute_new (state->vertex_array,
|
||||||
"cogl_color_in",
|
"cogl_color_in",
|
||||||
stride,
|
stride,
|
||||||
state->array_offset + (POS_STRIDE * 4),
|
state->array_offset + (POS_STRIDE * 4),
|
||||||
4,
|
4,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GL
|
#ifndef HAVE_COGL_GL
|
||||||
state->indices = cogl_get_rectangle_indices (batch_len);
|
state->indices = cogl_get_rectangle_indices (batch_len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We only create new VertexAttributes when the stride within the
|
/* We only create new Attributes when the stride within the
|
||||||
* VertexArray changes. (due to a change in the number of pipeline layers)
|
* VertexArray changes. (due to a change in the number of pipeline
|
||||||
* While the stride remains constant we walk forward through the above
|
* layers) While the stride remains constant we walk forward through
|
||||||
* VertexArray using a vertex offset passed to cogl_draw_vertex_attributes
|
* the above VertexArray using a vertex offset passed to
|
||||||
|
* cogl_draw_attributes
|
||||||
*/
|
*/
|
||||||
state->current_vertex = 0;
|
state->current_vertex = 0;
|
||||||
|
|
||||||
@ -1376,8 +1372,7 @@ _cogl_journal_flush (CoglJournal *journal,
|
|||||||
&state); /* data */
|
&state); /* data */
|
||||||
|
|
||||||
for (i = 0; i < state.attributes->len; i++)
|
for (i = 0; i < state.attributes->len; i++)
|
||||||
cogl_object_unref (g_array_index (state.attributes,
|
cogl_object_unref (g_array_index (state.attributes, CoglAttribute *, i));
|
||||||
CoglVertexAttribute *, i));
|
|
||||||
g_array_set_size (state.attributes, 0);
|
g_array_set_size (state.attributes, 0);
|
||||||
|
|
||||||
cogl_object_unref (state.vertex_array);
|
cogl_object_unref (state.vertex_array);
|
||||||
|
@ -82,10 +82,10 @@ struct _CoglPathData
|
|||||||
CoglVertexArray *fill_vbo;
|
CoglVertexArray *fill_vbo;
|
||||||
CoglIndices *fill_vbo_indices;
|
CoglIndices *fill_vbo_indices;
|
||||||
unsigned int fill_vbo_n_indices;
|
unsigned int fill_vbo_n_indices;
|
||||||
CoglVertexAttribute *fill_vbo_attributes[COGL_PATH_N_ATTRIBUTES + 1];
|
CoglAttribute *fill_vbo_attributes[COGL_PATH_N_ATTRIBUTES + 1];
|
||||||
|
|
||||||
CoglVertexArray *stroke_vbo;
|
CoglVertexArray *stroke_vbo;
|
||||||
CoglVertexAttribute **stroke_vbo_attributes;
|
CoglAttribute **stroke_vbo_attributes;
|
||||||
unsigned int stroke_vbo_n_attributes;
|
unsigned int stroke_vbo_n_attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#define __COGL_PIPELINE_PROGEND_GLSL_PRIVATE_H
|
#define __COGL_PIPELINE_PROGEND_GLSL_PRIVATE_H
|
||||||
|
|
||||||
#include "cogl-pipeline-private.h"
|
#include "cogl-pipeline-private.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
|
|
||||||
extern const CoglPipelineProgend _cogl_pipeline_glsl_progend;
|
extern const CoglPipelineProgend _cogl_pipeline_glsl_progend;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "cogl-object-private.h"
|
#include "cogl-object-private.h"
|
||||||
#include "cogl-primitive.h"
|
#include "cogl-primitive.h"
|
||||||
#include "cogl-primitive-private.h"
|
#include "cogl-primitive-private.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ COGL_OBJECT_DEFINE (Primitive, primitive);
|
|||||||
CoglPrimitive *
|
CoglPrimitive *
|
||||||
cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes)
|
CoglAttribute **attributes)
|
||||||
{
|
{
|
||||||
CoglPrimitive *primitive = g_slice_new (CoglPrimitive);
|
CoglPrimitive *primitive = g_slice_new (CoglPrimitive);
|
||||||
int i;
|
int i;
|
||||||
@ -54,15 +54,15 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
|||||||
primitive->n_vertices = n_vertices;
|
primitive->n_vertices = n_vertices;
|
||||||
primitive->indices = NULL;
|
primitive->indices = NULL;
|
||||||
primitive->attributes =
|
primitive->attributes =
|
||||||
g_array_new (TRUE, FALSE, sizeof (CoglVertexAttribute *));
|
g_array_new (TRUE, FALSE, sizeof (CoglAttribute *));
|
||||||
primitive->immutable_ref = 0;
|
primitive->immutable_ref = 0;
|
||||||
|
|
||||||
for (i = 0; attributes[i]; i++)
|
for (i = 0; attributes[i]; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute = attributes[i];
|
CoglAttribute *attribute = attributes[i];
|
||||||
cogl_object_ref (attribute);
|
cogl_object_ref (attribute);
|
||||||
|
|
||||||
g_return_val_if_fail (cogl_is_vertex_attribute (attribute), NULL);
|
g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
|
||||||
|
|
||||||
g_array_append_val (primitive->attributes, attribute);
|
g_array_append_val (primitive->attributes, attribute);
|
||||||
}
|
}
|
||||||
@ -74,10 +74,9 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
|||||||
new_with_attributes that also unrefs the attributes. It is just
|
new_with_attributes that also unrefs the attributes. It is just
|
||||||
used for the builtin struct constructors */
|
used for the builtin struct constructors */
|
||||||
static CoglPrimitive *
|
static CoglPrimitive *
|
||||||
_cogl_primitive_new_with_attributes_array_unref
|
_cogl_primitive_new_with_attributes_array_unref (CoglVerticesMode mode,
|
||||||
(CoglVerticesMode mode,
|
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes)
|
CoglAttribute **attributes)
|
||||||
{
|
{
|
||||||
CoglPrimitive *primitive;
|
CoglPrimitive *primitive;
|
||||||
int i;
|
int i;
|
||||||
@ -99,20 +98,20 @@ cogl_primitive_new (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int n_attributes;
|
int n_attributes;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
int i;
|
int i;
|
||||||
CoglVertexAttribute *attribute;
|
CoglAttribute *attribute;
|
||||||
|
|
||||||
va_start (ap, n_vertices);
|
va_start (ap, n_vertices);
|
||||||
for (n_attributes = 0; va_arg (ap, CoglVertexAttribute *); n_attributes++)
|
for (n_attributes = 0; va_arg (ap, CoglAttribute *); n_attributes++)
|
||||||
;
|
;
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1));
|
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
|
||||||
attributes[n_attributes] = NULL;
|
attributes[n_attributes] = NULL;
|
||||||
|
|
||||||
va_start (ap, n_vertices);
|
va_start (ap, n_vertices);
|
||||||
for (i = 0; (attribute = va_arg (ap, CoglVertexAttribute *)); i++)
|
for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++)
|
||||||
attributes[i] = attribute;
|
attributes[i] = attribute;
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
@ -127,15 +126,14 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2), data);
|
||||||
CoglVertexAttribute *attributes[2];
|
CoglAttribute *attributes[2];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP2),
|
sizeof (CoglVertexP2),
|
||||||
offsetof (CoglVertexP2, x),
|
offsetof (CoglVertexP2, x),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] = NULL;
|
attributes[1] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -151,15 +149,14 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3), data);
|
||||||
CoglVertexAttribute *attributes[2];
|
CoglAttribute *attributes[2];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP3),
|
sizeof (CoglVertexP3),
|
||||||
offsetof (CoglVertexP3, x),
|
offsetof (CoglVertexP3, x),
|
||||||
3,
|
3,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] = NULL;
|
attributes[1] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -175,22 +172,20 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2C4), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2C4), data);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglAttribute *attributes[3];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP2C4),
|
sizeof (CoglVertexP2C4),
|
||||||
offsetof (CoglVertexP2C4, x),
|
offsetof (CoglVertexP2C4, x),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] =
|
attributes[1] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_color_in",
|
"cogl_color_in",
|
||||||
sizeof (CoglVertexP2C4),
|
sizeof (CoglVertexP2C4),
|
||||||
offsetof (CoglVertexP2C4, r),
|
offsetof (CoglVertexP2C4, r),
|
||||||
4,
|
4,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||||
attributes[2] = NULL;
|
attributes[2] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -206,22 +201,20 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3C4), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3C4), data);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglAttribute *attributes[3];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP3C4),
|
sizeof (CoglVertexP3C4),
|
||||||
offsetof (CoglVertexP3C4, x),
|
offsetof (CoglVertexP3C4, x),
|
||||||
3,
|
3,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] =
|
attributes[1] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_color_in",
|
"cogl_color_in",
|
||||||
sizeof (CoglVertexP3C4),
|
sizeof (CoglVertexP3C4),
|
||||||
offsetof (CoglVertexP3C4, r),
|
offsetof (CoglVertexP3C4, r),
|
||||||
4,
|
4,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||||
attributes[2] = NULL;
|
attributes[2] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -237,22 +230,20 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2), data);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglAttribute *attributes[3];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP2T2),
|
sizeof (CoglVertexP2T2),
|
||||||
offsetof (CoglVertexP2T2, x),
|
offsetof (CoglVertexP2T2, x),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] =
|
attributes[1] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_tex_coord0_in",
|
"cogl_tex_coord0_in",
|
||||||
sizeof (CoglVertexP2T2),
|
sizeof (CoglVertexP2T2),
|
||||||
offsetof (CoglVertexP2T2, s),
|
offsetof (CoglVertexP2T2, s),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[2] = NULL;
|
attributes[2] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -268,22 +259,20 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2), data);
|
||||||
CoglVertexAttribute *attributes[3];
|
CoglAttribute *attributes[3];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP3T2),
|
sizeof (CoglVertexP3T2),
|
||||||
offsetof (CoglVertexP3T2, x),
|
offsetof (CoglVertexP3T2, x),
|
||||||
3,
|
3,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] =
|
attributes[1] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_tex_coord0_in",
|
"cogl_tex_coord0_in",
|
||||||
sizeof (CoglVertexP3T2),
|
sizeof (CoglVertexP3T2),
|
||||||
offsetof (CoglVertexP3T2, s),
|
offsetof (CoglVertexP3T2, s),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[2] = NULL;
|
attributes[2] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -299,29 +288,26 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2C4), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2C4), data);
|
||||||
CoglVertexAttribute *attributes[4];
|
CoglAttribute *attributes[4];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP2T2C4),
|
sizeof (CoglVertexP2T2C4),
|
||||||
offsetof (CoglVertexP2T2C4, x),
|
offsetof (CoglVertexP2T2C4, x),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] =
|
attributes[1] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_tex_coord0_in",
|
"cogl_tex_coord0_in",
|
||||||
sizeof (CoglVertexP2T2C4),
|
sizeof (CoglVertexP2T2C4),
|
||||||
offsetof (CoglVertexP2T2C4, s),
|
offsetof (CoglVertexP2T2C4, s),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[2] =
|
attributes[2] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_color_in",
|
"cogl_color_in",
|
||||||
sizeof (CoglVertexP2T2C4),
|
sizeof (CoglVertexP2T2C4),
|
||||||
offsetof (CoglVertexP2T2C4, r),
|
offsetof (CoglVertexP2T2C4, r),
|
||||||
4,
|
4,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||||
attributes[3] = NULL;
|
attributes[3] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -337,29 +323,26 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
|
|||||||
{
|
{
|
||||||
CoglVertexArray *array =
|
CoglVertexArray *array =
|
||||||
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2C4), data);
|
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2C4), data);
|
||||||
CoglVertexAttribute *attributes[4];
|
CoglAttribute *attributes[4];
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglVertexP3T2C4),
|
sizeof (CoglVertexP3T2C4),
|
||||||
offsetof (CoglVertexP3T2C4, x),
|
offsetof (CoglVertexP3T2C4, x),
|
||||||
3,
|
3,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] =
|
attributes[1] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_tex_coord0_in",
|
"cogl_tex_coord0_in",
|
||||||
sizeof (CoglVertexP3T2C4),
|
sizeof (CoglVertexP3T2C4),
|
||||||
offsetof (CoglVertexP3T2C4, s),
|
offsetof (CoglVertexP3T2C4, s),
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[2] =
|
attributes[2] = cogl_attribute_new (array,
|
||||||
cogl_vertex_attribute_new (array,
|
|
||||||
"cogl_color_in",
|
"cogl_color_in",
|
||||||
sizeof (CoglVertexP3T2C4),
|
sizeof (CoglVertexP3T2C4),
|
||||||
offsetof (CoglVertexP3T2C4, r),
|
offsetof (CoglVertexP3T2C4, r),
|
||||||
4,
|
4,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||||
attributes[3] = NULL;
|
attributes[3] = NULL;
|
||||||
|
|
||||||
cogl_object_unref (array);
|
cogl_object_unref (array);
|
||||||
@ -375,8 +358,8 @@ free_attributes_list (CoglPrimitive *primitive)
|
|||||||
|
|
||||||
for (i = 0; i < primitive->attributes->len; i++)
|
for (i = 0; i < primitive->attributes->len; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute =
|
CoglAttribute *attribute =
|
||||||
g_array_index (primitive->attributes, CoglVertexAttribute *, i);
|
g_array_index (primitive->attributes, CoglAttribute *, i);
|
||||||
cogl_object_unref (attribute);
|
cogl_object_unref (attribute);
|
||||||
}
|
}
|
||||||
g_array_set_size (primitive->attributes, 0);
|
g_array_set_size (primitive->attributes, 0);
|
||||||
@ -406,7 +389,7 @@ warn_about_midscene_changes (void)
|
|||||||
|
|
||||||
void
|
void
|
||||||
cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
||||||
CoglVertexAttribute **attributes)
|
CoglAttribute **attributes)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -424,7 +407,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
|||||||
for (i = 0; attributes[i]; i++)
|
for (i = 0; attributes[i]; i++)
|
||||||
{
|
{
|
||||||
cogl_object_ref (attributes[i]);
|
cogl_object_ref (attributes[i]);
|
||||||
g_return_if_fail (cogl_is_vertex_attribute (attributes[i]));
|
g_return_if_fail (cogl_is_attribute (attributes[i]));
|
||||||
g_array_append_val (primitive->attributes, attributes[i]);
|
g_array_append_val (primitive->attributes, attributes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -522,9 +505,9 @@ _cogl_primitive_immutable_ref (CoglPrimitive *primitive)
|
|||||||
|
|
||||||
for (i = 0; i < primitive->attributes->len; i++)
|
for (i = 0; i < primitive->attributes->len; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute =
|
CoglAttribute *attribute =
|
||||||
g_array_index (primitive->attributes, CoglVertexAttribute *, i);
|
g_array_index (primitive->attributes, CoglAttribute *, i);
|
||||||
_cogl_vertex_attribute_immutable_ref (attribute);
|
_cogl_attribute_immutable_ref (attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
return primitive;
|
return primitive;
|
||||||
@ -542,9 +525,9 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive)
|
|||||||
|
|
||||||
for (i = 0; i < primitive->attributes->len; i++)
|
for (i = 0; i < primitive->attributes->len; i++)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute *attribute =
|
CoglAttribute *attribute =
|
||||||
g_array_index (primitive->attributes, CoglVertexAttribute *, i);
|
g_array_index (primitive->attributes, CoglAttribute *, i);
|
||||||
_cogl_vertex_attribute_immutable_unref (attribute);
|
_cogl_attribute_immutable_unref (attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,17 +535,17 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive)
|
|||||||
void
|
void
|
||||||
cogl_primitive_draw (CoglPrimitive *primitive)
|
cogl_primitive_draw (CoglPrimitive *primitive)
|
||||||
{
|
{
|
||||||
CoglVertexAttribute **attributes =
|
CoglAttribute **attributes =
|
||||||
(CoglVertexAttribute **)primitive->attributes->data;
|
(CoglAttribute **)primitive->attributes->data;
|
||||||
|
|
||||||
if (primitive->indices)
|
if (primitive->indices)
|
||||||
cogl_draw_indexed_vertex_attributes_array (primitive->mode,
|
cogl_draw_indexed_attributes_array (primitive->mode,
|
||||||
primitive->first_vertex,
|
primitive->first_vertex,
|
||||||
primitive->n_vertices,
|
primitive->n_vertices,
|
||||||
primitive->indices,
|
primitive->indices,
|
||||||
attributes);
|
attributes);
|
||||||
else
|
else
|
||||||
cogl_draw_vertex_attributes_array (primitive->mode,
|
cogl_draw_attributes_array (primitive->mode,
|
||||||
primitive->first_vertex,
|
primitive->first_vertex,
|
||||||
primitive->n_vertices,
|
primitive->n_vertices,
|
||||||
attributes);
|
attributes);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define __COGL_PRIMITIVE_H__
|
#define __COGL_PRIMITIVE_H__
|
||||||
|
|
||||||
#include <cogl/cogl-vertex-buffer.h> /* for CoglVerticesMode */
|
#include <cogl/cogl-vertex-buffer.h> /* for CoglVerticesMode */
|
||||||
#include <cogl/cogl-vertex-attribute.h>
|
#include <cogl/cogl-attribute.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ typedef struct
|
|||||||
* @n_vertices: The number of vertices to process when drawing
|
* @n_vertices: The number of vertices to process when drawing
|
||||||
* @Varargs: A %NULL terminated list of attributes
|
* @Varargs: A %NULL terminated list of attributes
|
||||||
*
|
*
|
||||||
* Combines a set of #CoglVertexAttribute<!-- -->s with a specific draw @mode
|
* Combines a set of #CoglAttribute<!-- -->s with a specific draw @mode
|
||||||
* and defines a vertex count so a #CoglPrimitive object can be retained and
|
* and defines a vertex count so a #CoglPrimitive object can be retained and
|
||||||
* drawn later with no addition information required.
|
* drawn later with no addition information required.
|
||||||
*
|
*
|
||||||
@ -235,7 +235,7 @@ cogl_primitive_new (CoglVerticesMode mode,
|
|||||||
CoglPrimitive *
|
CoglPrimitive *
|
||||||
cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
||||||
int n_vertices,
|
int n_vertices,
|
||||||
CoglVertexAttribute **attributes);
|
CoglAttribute **attributes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_primitive_new_p2:
|
* cogl_primitive_new_p2:
|
||||||
@ -246,7 +246,7 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position
|
* necessary #CoglVertexArray storage, describe the position
|
||||||
* attribute with a #CoglVertexAttribute and upload your data.
|
* attribute with a #CoglAttribute and upload your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon you can do:
|
* For example to draw a convex polygon you can do:
|
||||||
* |[
|
* |[
|
||||||
@ -290,7 +290,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position
|
* necessary #CoglVertexArray storage, describe the position
|
||||||
* attribute with a #CoglVertexAttribute and upload your data.
|
* attribute with a #CoglAttribute and upload your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon you can do:
|
* For example to draw a convex polygon you can do:
|
||||||
* |[
|
* |[
|
||||||
@ -334,7 +334,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position
|
* necessary #CoglVertexArray storage, describe the position
|
||||||
* and color attributes with #CoglVertexAttribute<!-- -->s and upload
|
* and color attributes with #CoglAttribute<!-- -->s and upload
|
||||||
* your data.
|
* your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon with a linear gradient you
|
* For example to draw a convex polygon with a linear gradient you
|
||||||
@ -380,7 +380,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position
|
* necessary #CoglVertexArray storage, describe the position
|
||||||
* and color attributes with #CoglVertexAttribute<!-- -->s and upload
|
* and color attributes with #CoglAttribute<!-- -->s and upload
|
||||||
* your data.
|
* your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon with a linear gradient you
|
* For example to draw a convex polygon with a linear gradient you
|
||||||
@ -426,7 +426,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position and
|
* necessary #CoglVertexArray storage, describe the position and
|
||||||
* texture coordinate attributes with #CoglVertexAttribute<!-- -->s and
|
* texture coordinate attributes with #CoglAttribute<!-- -->s and
|
||||||
* upload your data.
|
* upload your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon with texture mapping you can
|
* For example to draw a convex polygon with texture mapping you can
|
||||||
@ -472,7 +472,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position and
|
* necessary #CoglVertexArray storage, describe the position and
|
||||||
* texture coordinate attributes with #CoglVertexAttribute<!-- -->s and
|
* texture coordinate attributes with #CoglAttribute<!-- -->s and
|
||||||
* upload your data.
|
* upload your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon with texture mapping you can
|
* For example to draw a convex polygon with texture mapping you can
|
||||||
@ -518,7 +518,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position, texture
|
* necessary #CoglVertexArray storage, describe the position, texture
|
||||||
* coordinate and color attributes with #CoglVertexAttribute<!-- -->s and
|
* coordinate and color attributes with #CoglAttribute<!-- -->s and
|
||||||
* upload your data.
|
* upload your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon with texture mapping and a
|
* For example to draw a convex polygon with texture mapping and a
|
||||||
@ -564,7 +564,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
|
|||||||
* Provides a convenient way to describe a primitive, such as a single
|
* Provides a convenient way to describe a primitive, such as a single
|
||||||
* triangle strip or a triangle fan, that will internally allocate the
|
* triangle strip or a triangle fan, that will internally allocate the
|
||||||
* necessary #CoglVertexArray storage, describe the position, texture
|
* necessary #CoglVertexArray storage, describe the position, texture
|
||||||
* coordinate and color attributes with #CoglVertexAttribute<!-- -->s and
|
* coordinate and color attributes with #CoglAttribute<!-- -->s and
|
||||||
* upload your data.
|
* upload your data.
|
||||||
*
|
*
|
||||||
* For example to draw a convex polygon with texture mapping and a
|
* For example to draw a convex polygon with texture mapping and a
|
||||||
@ -624,7 +624,7 @@ cogl_primitive_set_mode (CoglPrimitive *primitive,
|
|||||||
/**
|
/**
|
||||||
* cogl_primitive_set_attributes:
|
* cogl_primitive_set_attributes:
|
||||||
* @primitive: A #CoglPrimitive object
|
* @primitive: A #CoglPrimitive object
|
||||||
* @attributes: A %NULL terminated array of #CoglVertexAttribute
|
* @attributes: A %NULL terminated array of #CoglAttribute
|
||||||
* pointers
|
* pointers
|
||||||
*
|
*
|
||||||
* Replaces all the attributes of the given #CoglPrimitive object.
|
* Replaces all the attributes of the given #CoglPrimitive object.
|
||||||
@ -634,7 +634,7 @@ cogl_primitive_set_mode (CoglPrimitive *primitive,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
||||||
CoglVertexAttribute **attributes);
|
CoglAttribute **attributes);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "cogl-pipeline-opengl-private.h"
|
#include "cogl-pipeline-opengl-private.h"
|
||||||
#include "cogl-vertex-buffer-private.h"
|
#include "cogl-vertex-buffer-private.h"
|
||||||
#include "cogl-framebuffer-private.h"
|
#include "cogl-framebuffer-private.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -68,7 +68,7 @@ typedef struct _TextureSlicedPolygonState
|
|||||||
const CoglTextureVertex *vertices;
|
const CoglTextureVertex *vertices;
|
||||||
int n_vertices;
|
int n_vertices;
|
||||||
int stride;
|
int stride;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
} TextureSlicedPolygonState;
|
} TextureSlicedPolygonState;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -934,18 +934,18 @@ _cogl_rectangle_immediate (float x_1,
|
|||||||
x_2, y_2
|
x_2, y_2
|
||||||
};
|
};
|
||||||
CoglVertexArray *vertex_array;
|
CoglVertexArray *vertex_array;
|
||||||
CoglVertexAttribute *attributes[2];
|
CoglAttribute *attributes[2];
|
||||||
|
|
||||||
vertex_array = cogl_vertex_array_new (sizeof (vertices), vertices);
|
vertex_array = cogl_vertex_array_new (sizeof (vertices), vertices);
|
||||||
attributes[0] = cogl_vertex_attribute_new (vertex_array,
|
attributes[0] = cogl_attribute_new (vertex_array,
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (float) * 2, /* stride */
|
sizeof (float) * 2, /* stride */
|
||||||
0, /* offset */
|
0, /* offset */
|
||||||
2, /* n_components */
|
2, /* n_components */
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
attributes[1] = NULL;
|
attributes[1] = NULL;
|
||||||
|
|
||||||
_cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
_cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
||||||
0, /* first_index */
|
0, /* first_index */
|
||||||
4, /* n_vertices */
|
4, /* n_vertices */
|
||||||
attributes,
|
attributes,
|
||||||
@ -1046,7 +1046,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
ValidateState validate_state;
|
ValidateState validate_state;
|
||||||
int n_layers;
|
int n_layers;
|
||||||
int n_attributes;
|
int n_attributes;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
int i;
|
int i;
|
||||||
unsigned int stride;
|
unsigned int stride;
|
||||||
gsize stride_bytes;
|
gsize stride_bytes;
|
||||||
@ -1067,7 +1067,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
n_layers = cogl_pipeline_get_n_layers (pipeline);
|
n_layers = cogl_pipeline_get_n_layers (pipeline);
|
||||||
|
|
||||||
n_attributes = 1 + n_layers + (use_color ? 1 : 0);
|
n_attributes = 1 + n_layers + (use_color ? 1 : 0);
|
||||||
attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1));
|
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
|
||||||
attributes[n_attributes] = NULL;
|
attributes[n_attributes] = NULL;
|
||||||
|
|
||||||
/* Our data is arranged like:
|
/* Our data is arranged like:
|
||||||
@ -1082,13 +1082,12 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
|
|
||||||
vertex_array = cogl_vertex_array_new (n_vertices * stride_bytes, NULL);
|
vertex_array = cogl_vertex_array_new (n_vertices * stride_bytes, NULL);
|
||||||
|
|
||||||
attributes[0] =
|
attributes[0] = cogl_attribute_new (vertex_array,
|
||||||
cogl_vertex_attribute_new (vertex_array,
|
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
stride_bytes,
|
stride_bytes,
|
||||||
0,
|
0,
|
||||||
3,
|
3,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
|
|
||||||
for (i = 0; i < n_layers; i++)
|
for (i = 0; i < n_layers; i++)
|
||||||
{
|
{
|
||||||
@ -1105,26 +1104,25 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
char *name = i < 8 ? (char *)names[i] :
|
char *name = i < 8 ? (char *)names[i] :
|
||||||
g_strdup_printf ("cogl_tex_coord%d_in", i);
|
g_strdup_printf ("cogl_tex_coord%d_in", i);
|
||||||
|
|
||||||
attributes[i + 1] =
|
attributes[i + 1] = cogl_attribute_new (vertex_array,
|
||||||
cogl_vertex_attribute_new (vertex_array,
|
|
||||||
name,
|
name,
|
||||||
stride_bytes,
|
stride_bytes,
|
||||||
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
|
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
|
||||||
12 + 8 * i,
|
12 + 8 * i,
|
||||||
2,
|
2,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_color)
|
if (use_color)
|
||||||
{
|
{
|
||||||
attributes[n_attributes - 1] =
|
attributes[n_attributes - 1] =
|
||||||
cogl_vertex_attribute_new (vertex_array,
|
cogl_attribute_new (vertex_array,
|
||||||
"cogl_color_in",
|
"cogl_color_in",
|
||||||
stride_bytes,
|
stride_bytes,
|
||||||
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
|
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
|
||||||
12 + 8 * n_layers,
|
12 + 8 * n_layers,
|
||||||
4,
|
4,
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the vertices into an array of float vertex attributes */
|
/* Convert the vertices into an array of float vertex attributes */
|
||||||
@ -1168,7 +1166,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
|
|
||||||
cogl_push_source (pipeline);
|
cogl_push_source (pipeline);
|
||||||
|
|
||||||
cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
||||||
0, n_vertices,
|
0, n_vertices,
|
||||||
attributes);
|
attributes);
|
||||||
|
|
||||||
|
@ -471,6 +471,28 @@ typedef enum { /*< prefix=COGL_ERROR >*/
|
|||||||
GQuark
|
GQuark
|
||||||
_cogl_error_quark (void);
|
_cogl_error_quark (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglAttributeType:
|
||||||
|
* @COGL_ATTRIBUTE_TYPE_BYTE: Data is the same size of a byte
|
||||||
|
* @COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE: Data is the same size of an
|
||||||
|
* unsigned byte
|
||||||
|
* @COGL_ATTRIBUTE_TYPE_SHORT: Data is the same size of a short integer
|
||||||
|
* @COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT: Data is the same size of
|
||||||
|
* an unsigned short integer
|
||||||
|
* @COGL_ATTRIBUTE_TYPE_FLOAT: Data is the same size of a float
|
||||||
|
*
|
||||||
|
* Data types for the components of a vertex attribute.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
COGL_ATTRIBUTE_TYPE_BYTE = 0x1400,
|
||||||
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE = 0x1401,
|
||||||
|
COGL_ATTRIBUTE_TYPE_SHORT = 0x1402,
|
||||||
|
COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT = 0x1403,
|
||||||
|
COGL_ATTRIBUTE_TYPE_FLOAT = 0x1406
|
||||||
|
} CoglAttributeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglIndicesType:
|
* CoglIndicesType:
|
||||||
* @COGL_INDICES_TYPE_UNSIGNED_BYTE: Your indices are unsigned bytes
|
* @COGL_INDICES_TYPE_UNSIGNED_BYTE: Your indices are unsigned bytes
|
||||||
|
@ -93,14 +93,14 @@ typedef struct _CoglVertexBufferAttrib
|
|||||||
const void *pointer;
|
const void *pointer;
|
||||||
size_t vbo_offset;
|
size_t vbo_offset;
|
||||||
} u;
|
} u;
|
||||||
CoglVertexAttributeType type;
|
CoglAttributeType type;
|
||||||
size_t span_bytes;
|
size_t span_bytes;
|
||||||
guint16 stride;
|
guint16 stride;
|
||||||
guint8 n_components;
|
guint8 n_components;
|
||||||
guint8 texture_unit;
|
guint8 texture_unit;
|
||||||
|
|
||||||
int attribute_first;
|
int attribute_first;
|
||||||
CoglVertexAttribute *attribute;
|
CoglAttribute *attribute;
|
||||||
|
|
||||||
} CoglVertexBufferAttrib;
|
} CoglVertexBufferAttrib;
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ validate_custom_attribute_name (const char *attribute_name)
|
|||||||
* of all the submitted attributes
|
* of all the submitted attributes
|
||||||
*
|
*
|
||||||
* Note: The CoglVertexBufferAttrib structs are deep copied, except the
|
* Note: The CoglVertexBufferAttrib structs are deep copied, except the
|
||||||
* internal CoglVertexAttribute pointer is set to NULL.
|
* internal CoglAttribute pointer is set to NULL.
|
||||||
*/
|
*/
|
||||||
static GList *
|
static GList *
|
||||||
copy_submitted_attributes_list (CoglVertexBuffer *buffer)
|
copy_submitted_attributes_list (CoglVertexBuffer *buffer)
|
||||||
@ -1145,7 +1145,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
|
|||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
int n_attributes = 0;
|
int n_attributes = 0;
|
||||||
CoglVertexAttribute **attributes;
|
CoglAttribute **attributes;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!buffer->dirty_attributes)
|
if (!buffer->dirty_attributes)
|
||||||
@ -1164,7 +1164,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
|
|||||||
|
|
||||||
g_return_if_fail (n_attributes > 0);
|
g_return_if_fail (n_attributes > 0);
|
||||||
|
|
||||||
attributes = g_alloca (sizeof (CoglVertexAttribute *) * n_attributes + 1);
|
attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes + 1);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (l = buffer->submitted_vbos; l; l = l->next)
|
for (l = buffer->submitted_vbos; l; l = l->next)
|
||||||
@ -1181,7 +1181,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
|
|||||||
if (G_UNLIKELY (!attribute->attribute))
|
if (G_UNLIKELY (!attribute->attribute))
|
||||||
{
|
{
|
||||||
attribute->attribute =
|
attribute->attribute =
|
||||||
cogl_vertex_attribute_new (cogl_vbo->array,
|
cogl_attribute_new (cogl_vbo->array,
|
||||||
attribute->name_without_detail,
|
attribute->name_without_detail,
|
||||||
attribute->stride,
|
attribute->stride,
|
||||||
attribute->u.vbo_offset,
|
attribute->u.vbo_offset,
|
||||||
|
@ -97,28 +97,6 @@ cogl_vertex_buffer_new (unsigned int n_vertices);
|
|||||||
unsigned int
|
unsigned int
|
||||||
cogl_vertex_buffer_get_n_vertices (CoglHandle handle);
|
cogl_vertex_buffer_get_n_vertices (CoglHandle handle);
|
||||||
|
|
||||||
/**
|
|
||||||
* CoglAttributeType:
|
|
||||||
* @COGL_ATTRIBUTE_TYPE_BYTE: Data is the same size of a byte
|
|
||||||
* @COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE: Data is the same size of an
|
|
||||||
* unsigned byte
|
|
||||||
* @COGL_ATTRIBUTE_TYPE_SHORT: Data is the same size of a short integer
|
|
||||||
* @COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT: Data is the same size of
|
|
||||||
* an unsigned short integer
|
|
||||||
* @COGL_ATTRIBUTE_TYPE_FLOAT: Data is the same size of a float
|
|
||||||
*
|
|
||||||
* Data types for the components of cogl_vertex_buffer_add()
|
|
||||||
*
|
|
||||||
* Since: 1.0
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
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:
|
* cogl_vertex_buffer_add:
|
||||||
* @handle: A vertex buffer handle
|
* @handle: A vertex buffer handle
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "cogl-bitmap-private.h"
|
#include "cogl-bitmap-private.h"
|
||||||
#include "cogl-texture-private.h"
|
#include "cogl-texture-private.h"
|
||||||
#include "cogl-texture-driver.h"
|
#include "cogl-texture-driver.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
#include "cogl-framebuffer-private.h"
|
#include "cogl-framebuffer-private.h"
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
#ifdef HAVE_COGL_GL
|
||||||
@ -739,7 +739,7 @@ cogl_begin_gl (void)
|
|||||||
_cogl_flush_face_winding ();
|
_cogl_flush_face_winding ();
|
||||||
|
|
||||||
/* Disable any cached vertex arrays */
|
/* Disable any cached vertex arrays */
|
||||||
_cogl_vertex_attribute_disable_cached_arrays ();
|
_cogl_attribute_disable_cached_arrays ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
#include <cogl/cogl-index-array.h>
|
#include <cogl/cogl-index-array.h>
|
||||||
#include <cogl/cogl-vertex-array.h>
|
#include <cogl/cogl-vertex-array.h>
|
||||||
#include <cogl/cogl-indices.h>
|
#include <cogl/cogl-indices.h>
|
||||||
#include <cogl/cogl-vertex-attribute.h>
|
#include <cogl/cogl-attribute.h>
|
||||||
#include <cogl/cogl-primitive.h>
|
#include <cogl/cogl-primitive.h>
|
||||||
#include <cogl/cogl-pipeline.h>
|
#include <cogl/cogl-pipeline.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include "cogl-texture-private.h"
|
#include "cogl-texture-private.h"
|
||||||
#include "cogl-primitives-private.h"
|
#include "cogl-primitives-private.h"
|
||||||
#include "cogl-private.h"
|
#include "cogl-private.h"
|
||||||
#include "cogl-vertex-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
#include "tesselator/tesselator.h"
|
#include "tesselator/tesselator.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -233,7 +233,7 @@ _cogl_path_stroke_nodes (CoglPath *path)
|
|||||||
{
|
{
|
||||||
node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
|
node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
|
||||||
|
|
||||||
cogl_draw_vertex_attributes (COGL_VERTICES_MODE_LINE_STRIP,
|
cogl_draw_attributes (COGL_VERTICES_MODE_LINE_STRIP,
|
||||||
0, node->path_size,
|
0, node->path_size,
|
||||||
data->stroke_vbo_attributes[path_num],
|
data->stroke_vbo_attributes[path_num],
|
||||||
NULL);
|
NULL);
|
||||||
@ -338,7 +338,7 @@ _cogl_path_fill_nodes (CoglPath *path)
|
|||||||
|
|
||||||
_cogl_path_build_fill_vbo (path);
|
_cogl_path_build_fill_vbo (path);
|
||||||
|
|
||||||
_cogl_draw_indexed_vertex_attributes_array
|
_cogl_draw_indexed_attributes_array
|
||||||
(COGL_VERTICES_MODE_TRIANGLES,
|
(COGL_VERTICES_MODE_TRIANGLES,
|
||||||
0, /* first_vertex */
|
0, /* first_vertex */
|
||||||
path->data->fill_vbo_n_indices,
|
path->data->fill_vbo_n_indices,
|
||||||
@ -1447,19 +1447,19 @@ _cogl_path_build_fill_vbo (CoglPath *path)
|
|||||||
g_array_free (tess.vertices, TRUE);
|
g_array_free (tess.vertices, TRUE);
|
||||||
|
|
||||||
data->fill_vbo_attributes[0] =
|
data->fill_vbo_attributes[0] =
|
||||||
cogl_vertex_attribute_new (data->fill_vbo,
|
cogl_attribute_new (data->fill_vbo,
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (CoglPathTesselatorVertex),
|
sizeof (CoglPathTesselatorVertex),
|
||||||
G_STRUCT_OFFSET (CoglPathTesselatorVertex, x),
|
G_STRUCT_OFFSET (CoglPathTesselatorVertex, x),
|
||||||
2, /* n_components */
|
2, /* n_components */
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
data->fill_vbo_attributes[1] =
|
data->fill_vbo_attributes[1] =
|
||||||
cogl_vertex_attribute_new (data->fill_vbo,
|
cogl_attribute_new (data->fill_vbo,
|
||||||
"cogl_tex_coord0_in",
|
"cogl_tex_coord0_in",
|
||||||
sizeof (CoglPathTesselatorVertex),
|
sizeof (CoglPathTesselatorVertex),
|
||||||
G_STRUCT_OFFSET (CoglPathTesselatorVertex, s),
|
G_STRUCT_OFFSET (CoglPathTesselatorVertex, s),
|
||||||
2, /* n_components */
|
2, /* n_components */
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
/* NULL terminator */
|
/* NULL terminator */
|
||||||
data->fill_vbo_attributes[2] = NULL;
|
data->fill_vbo_attributes[2] = NULL;
|
||||||
|
|
||||||
@ -1511,7 +1511,7 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
|
|||||||
|
|
||||||
_cogl_buffer_unmap_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo));
|
_cogl_buffer_unmap_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo));
|
||||||
|
|
||||||
data->stroke_vbo_attributes = g_new (CoglVertexAttribute *, n_attributes);
|
data->stroke_vbo_attributes = g_new (CoglAttribute *, n_attributes);
|
||||||
|
|
||||||
/* Now we can loop the sub paths again to create the attributes */
|
/* Now we can loop the sub paths again to create the attributes */
|
||||||
for (i = 0, path_start = 0;
|
for (i = 0, path_start = 0;
|
||||||
@ -1521,12 +1521,12 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
|
|||||||
node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
|
node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
|
||||||
|
|
||||||
data->stroke_vbo_attributes[i] =
|
data->stroke_vbo_attributes[i] =
|
||||||
cogl_vertex_attribute_new (data->stroke_vbo,
|
cogl_attribute_new (data->stroke_vbo,
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (floatVec2),
|
sizeof (floatVec2),
|
||||||
path_start * sizeof (floatVec2),
|
path_start * sizeof (floatVec2),
|
||||||
2, /* n_components */
|
2, /* n_components */
|
||||||
COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->stroke_vbo_n_attributes = n_attributes;
|
data->stroke_vbo_n_attributes = n_attributes;
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
<section id="cogl-buffer-layout-apis">
|
<section id="cogl-buffer-layout-apis">
|
||||||
<title>Describing the layout of GPU Memory</title>
|
<title>Describing the layout of GPU Memory</title>
|
||||||
<xi:include href="xml/cogl-vertex-attribute.xml"/>
|
<xi:include href="xml/cogl-attribute.xml"/>
|
||||||
<xi:include href="xml/cogl-indices.xml"/>
|
<xi:include href="xml/cogl-indices.xml"/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user