Don't pass around NULL terminated CoglAttribute arrays
For the first iteration of the CoglAttribute API several of the new functions accepted a pointer to a NULL terminated list of CoglAttribute pointers - probably as a way to reduce the number of arguments required. This style isn't consistent with existing Cogl APIs though and so we now explicitly pass n_attributes arguments and don't require the NULL termination.
This commit is contained in:
parent
bf7653ac93
commit
3c1e83c7f5
@ -82,19 +82,21 @@ void
|
||||
_cogl_attribute_immutable_unref (CoglAttribute *attribute);
|
||||
|
||||
void
|
||||
_cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
CoglDrawFlags flags);
|
||||
_cogl_draw_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
CoglDrawFlags flags);
|
||||
|
||||
void
|
||||
_cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
CoglAttribute **attributes,
|
||||
CoglDrawFlags flags);
|
||||
_cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
CoglDrawFlags flags);
|
||||
|
||||
void
|
||||
_cogl_attribute_disable_cached_arrays (void);
|
||||
|
@ -478,6 +478,7 @@ set_enabled_arrays (CoglBitmask *value_cache,
|
||||
static CoglHandle
|
||||
enable_gl_state (CoglDrawFlags flags,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
ValidateLayerState *state)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
|
||||
@ -504,7 +505,7 @@ enable_gl_state (CoglDrawFlags flags,
|
||||
/* Iterate the attributes to work out whether blending needs to be
|
||||
enabled and how many texture coords there are. We need to do this
|
||||
before flushing the pipeline. */
|
||||
for (i = 0; attributes[i]; i++)
|
||||
for (i = 0; i < n_attributes; i++)
|
||||
switch (attributes[i]->name_id)
|
||||
{
|
||||
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
||||
@ -595,7 +596,7 @@ enable_gl_state (CoglDrawFlags flags,
|
||||
pipeline is flushed because on GLES2 that is the only point when
|
||||
we can determine the attribute locations */
|
||||
|
||||
for (i = 0; attributes[i]; i++)
|
||||
for (i = 0; i < n_attributes; i++)
|
||||
{
|
||||
CoglAttribute *attribute = attributes[i];
|
||||
CoglAttributeBuffer *attribute_buffer;
|
||||
@ -767,6 +768,7 @@ _cogl_attribute_disable_cached_arrays (void)
|
||||
* just disable the things not needed after enabling state. */
|
||||
static void
|
||||
disable_gl_state (CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
CoglPipeline *source)
|
||||
{
|
||||
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
||||
@ -779,7 +781,7 @@ disable_gl_state (CoglAttribute **attributes,
|
||||
if (G_UNLIKELY (source != cogl_get_source ()))
|
||||
cogl_object_unref (source);
|
||||
|
||||
for (i = 0; attributes[i]; i++)
|
||||
for (i = 0; i < n_attributes; i++)
|
||||
{
|
||||
CoglAttribute *attribute = attributes[i];
|
||||
|
||||
@ -995,17 +997,18 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
CoglIndices *indices)
|
||||
{
|
||||
CoglAttribute *position = NULL;
|
||||
int i;
|
||||
int n_line_vertices;
|
||||
static CoglPipeline *wire_pipeline;
|
||||
CoglAttribute *wire_attribute[2];
|
||||
CoglAttribute *wire_attribute[1];
|
||||
CoglVertexP3 *lines;
|
||||
CoglAttributeBuffer *attribute_buffer;
|
||||
|
||||
for (i = 0; attributes[i]; i++)
|
||||
for (i = 0; i < n_attributes; i++)
|
||||
{
|
||||
if (strcmp (attributes[i]->name, "cogl_position_in") == 0)
|
||||
{
|
||||
@ -1030,7 +1033,6 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
0,
|
||||
3,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
wire_attribute[1] = NULL;
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
if (!wire_pipeline)
|
||||
@ -1044,14 +1046,15 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
|
||||
/* temporarily disable the wireframe to avoid recursion! */
|
||||
COGL_DEBUG_CLEAR_FLAG (COGL_DEBUG_WIREFRAME);
|
||||
_cogl_draw_attributes_array (COGL_VERTICES_MODE_LINES,
|
||||
0,
|
||||
n_line_vertices,
|
||||
wire_attribute,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
|
||||
COGL_DRAW_SKIP_LEGACY_STATE);
|
||||
_cogl_draw_attributes (COGL_VERTICES_MODE_LINES,
|
||||
0,
|
||||
n_line_vertices,
|
||||
wire_attribute,
|
||||
1,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
|
||||
COGL_DRAW_SKIP_LEGACY_STATE);
|
||||
|
||||
COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME);
|
||||
|
||||
@ -1096,47 +1099,51 @@ flush_state (CoglDrawFlags flags,
|
||||
* skipping the implicit journal flush, the framebuffer flush and
|
||||
* pipeline validation. */
|
||||
void
|
||||
_cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
CoglDrawFlags flags)
|
||||
_cogl_draw_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
CoglDrawFlags flags)
|
||||
{
|
||||
ValidateLayerState state;
|
||||
CoglPipeline *source;
|
||||
|
||||
flush_state (flags, &state);
|
||||
|
||||
source = enable_gl_state (flags, attributes, &state);
|
||||
source = enable_gl_state (flags, attributes, n_attributes, &state);
|
||||
|
||||
GE (glDrawArrays ((GLenum)mode, first_vertex, n_vertices));
|
||||
|
||||
/* FIXME: we shouldn't be disabling state after drawing we should
|
||||
* just disable the things not needed after enabling state. */
|
||||
disable_gl_state (attributes, source);
|
||||
disable_gl_state (attributes, n_attributes, source);
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME)))
|
||||
draw_wireframe (mode, first_vertex, n_vertices, attributes, NULL);
|
||||
draw_wireframe (mode, first_vertex, n_vertices,
|
||||
attributes, n_attributes, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes)
|
||||
{
|
||||
_cogl_draw_attributes_array (mode, first_vertex,
|
||||
n_vertices, attributes,
|
||||
0 /* no flags */);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
...)
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes)
|
||||
{
|
||||
_cogl_draw_attributes (mode, first_vertex,
|
||||
n_vertices,
|
||||
attributes, n_attributes,
|
||||
0 /* no flags */);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vdraw_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
int n_attributes;
|
||||
@ -1157,8 +1164,8 @@ cogl_draw_attributes (CoglVerticesMode mode,
|
||||
attributes[i] = attribute;
|
||||
va_end (ap);
|
||||
|
||||
cogl_draw_attributes_array (mode, first_vertex, n_vertices,
|
||||
attributes);
|
||||
cogl_draw_attributes (mode, first_vertex, n_vertices,
|
||||
attributes, i + 1);
|
||||
}
|
||||
|
||||
static size_t
|
||||
@ -1177,12 +1184,13 @@ sizeof_index_type (CoglIndicesType type)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
CoglAttribute **attributes,
|
||||
CoglDrawFlags flags)
|
||||
_cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes,
|
||||
CoglDrawFlags flags)
|
||||
{
|
||||
ValidateLayerState state;
|
||||
CoglPipeline *source;
|
||||
@ -1196,7 +1204,7 @@ _cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
|
||||
flush_state (flags, &state);
|
||||
|
||||
source = enable_gl_state (flags, attributes, &state);
|
||||
source = enable_gl_state (flags, attributes, n_attributes, &state);
|
||||
|
||||
buffer = COGL_BUFFER (cogl_indices_get_buffer (indices));
|
||||
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER);
|
||||
@ -1225,32 +1233,35 @@ _cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
|
||||
/* FIXME: we shouldn't be disabling state after drawing we should
|
||||
* just disable the things not needed after enabling state. */
|
||||
disable_gl_state (attributes, source);
|
||||
disable_gl_state (attributes, n_attributes, source);
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME)))
|
||||
draw_wireframe (mode, first_vertex, n_vertices, attributes, indices);
|
||||
draw_wireframe (mode, first_vertex, n_vertices,
|
||||
attributes, n_attributes, indices);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
CoglAttribute **attributes)
|
||||
{
|
||||
_cogl_draw_indexed_attributes_array (mode, first_vertex,
|
||||
n_vertices, indices, attributes,
|
||||
0 /* no flags */);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
...)
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes)
|
||||
{
|
||||
_cogl_draw_indexed_attributes (mode, first_vertex,
|
||||
n_vertices, indices,
|
||||
attributes, n_attributes,
|
||||
0 /* no flags */);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_vdraw_indexed_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
int n_attributes;
|
||||
@ -1271,11 +1282,12 @@ cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||
attributes[i] = attribute;
|
||||
va_end (ap);
|
||||
|
||||
cogl_draw_indexed_attributes_array (mode,
|
||||
first_vertex,
|
||||
n_vertices,
|
||||
indices,
|
||||
attributes);
|
||||
cogl_draw_indexed_attributes (mode,
|
||||
first_vertex,
|
||||
n_vertices,
|
||||
indices,
|
||||
attributes,
|
||||
n_attributes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,31 +151,33 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
||||
gboolean
|
||||
cogl_is_attribute (void *object);
|
||||
|
||||
void
|
||||
cogl_vdraw_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void
|
||||
cogl_draw_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes);
|
||||
|
||||
void
|
||||
cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes);
|
||||
cogl_vdraw_indexed_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void
|
||||
cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void
|
||||
cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
int first_vertex,
|
||||
int n_vertices,
|
||||
CoglIndices *indices,
|
||||
CoglAttribute **attributes);
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -296,28 +296,31 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
||||
#ifdef HAVE_COGL_GL
|
||||
|
||||
/* XXX: it's rather evil that we sneak in the GL_QUADS enum here... */
|
||||
_cogl_draw_attributes_array (GL_QUADS,
|
||||
state->current_vertex, batch_len * 4,
|
||||
attributes,
|
||||
draw_flags);
|
||||
_cogl_draw_attributes (GL_QUADS,
|
||||
state->current_vertex, batch_len * 4,
|
||||
attributes,
|
||||
state->attributes->len,
|
||||
draw_flags);
|
||||
|
||||
#else /* HAVE_COGL_GL */
|
||||
if (batch_len > 1)
|
||||
{
|
||||
_cogl_draw_indexed_attributes_array (COGL_VERTICES_MODE_TRIANGLES,
|
||||
state->current_vertex * 6 / 4,
|
||||
batch_len * 6,
|
||||
state->indices,
|
||||
attributes,
|
||||
draw_flags);
|
||||
_cogl_draw_indexed_attributes (COGL_VERTICES_MODE_TRIANGLES,
|
||||
state->current_vertex * 6 / 4,
|
||||
batch_len * 6,
|
||||
state->indices,
|
||||
attributes,
|
||||
state->attributes->len,
|
||||
draw_flags);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
||||
state->current_vertex, 4,
|
||||
attributes,
|
||||
draw_flags);
|
||||
_cogl_draw_attributes (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
||||
state->current_vertex, 4,
|
||||
attributes,
|
||||
state->attributes->len,
|
||||
draw_flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -332,7 +335,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
||||
static CoglPipeline *outline = NULL;
|
||||
guint8 color_intensity;
|
||||
int i;
|
||||
CoglAttribute *loop_attributes[2];
|
||||
CoglAttribute *loop_attributes[1];
|
||||
|
||||
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
||||
|
||||
@ -358,12 +361,12 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
||||
cogl_set_source (outline);
|
||||
|
||||
loop_attributes[0] = attributes[0]; /* we just want the position */
|
||||
loop_attributes[1] = NULL;
|
||||
for (i = 0; i < batch_len; i++)
|
||||
_cogl_draw_attributes_array (COGL_VERTICES_MODE_LINE_LOOP,
|
||||
4 * i + state->current_vertex, 4,
|
||||
loop_attributes,
|
||||
draw_flags);
|
||||
_cogl_draw_attributes (COGL_VERTICES_MODE_LINE_LOOP,
|
||||
4 * i + state->current_vertex, 4,
|
||||
loop_attributes,
|
||||
1,
|
||||
draw_flags);
|
||||
|
||||
/* Go to the next color */
|
||||
do
|
||||
|
@ -40,11 +40,11 @@ static void _cogl_primitive_free (CoglPrimitive *primitive);
|
||||
|
||||
COGL_OBJECT_DEFINE (Primitive, primitive);
|
||||
|
||||
/* XXX: should we have an n_attributes arg instead of NULL terminating? */
|
||||
CoglPrimitive *
|
||||
cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes)
|
||||
cogl_primitive_new_with_attributes (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes)
|
||||
{
|
||||
CoglPrimitive *primitive = g_slice_new (CoglPrimitive);
|
||||
int i;
|
||||
@ -57,7 +57,7 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
||||
g_array_new (TRUE, FALSE, sizeof (CoglAttribute *));
|
||||
primitive->immutable_ref = 0;
|
||||
|
||||
for (i = 0; attributes[i]; i++)
|
||||
for (i = 0; i < n_attributes; i++)
|
||||
{
|
||||
CoglAttribute *attribute = attributes[i];
|
||||
cogl_object_ref (attribute);
|
||||
@ -74,16 +74,18 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
||||
new_with_attributes that also unrefs the attributes. It is just
|
||||
used for the builtin struct constructors */
|
||||
static CoglPrimitive *
|
||||
_cogl_primitive_new_with_attributes_array_unref (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes)
|
||||
_cogl_primitive_new_with_attributes_unref (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes)
|
||||
{
|
||||
CoglPrimitive *primitive;
|
||||
int i;
|
||||
|
||||
primitive = cogl_primitive_new_with_attributes_array (mode,
|
||||
n_vertices,
|
||||
attributes);
|
||||
primitive = cogl_primitive_new_with_attributes (mode,
|
||||
n_vertices,
|
||||
attributes,
|
||||
n_attributes);
|
||||
|
||||
for (i = 0; attributes[i]; i++)
|
||||
cogl_object_unref (attributes[i]);
|
||||
@ -115,8 +117,9 @@ cogl_primitive_new (CoglVerticesMode mode,
|
||||
attributes[i] = attribute;
|
||||
va_end (ap);
|
||||
|
||||
return cogl_primitive_new_with_attributes_array (mode, n_vertices,
|
||||
attributes);
|
||||
return cogl_primitive_new_with_attributes (mode, n_vertices,
|
||||
attributes,
|
||||
i + 1);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -126,7 +129,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2), data);
|
||||
CoglAttribute *attributes[2];
|
||||
CoglAttribute *attributes[1];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -134,12 +137,12 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP2, x),
|
||||
2,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
attributes[1] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
1);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -149,7 +152,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3), data);
|
||||
CoglAttribute *attributes[2];
|
||||
CoglAttribute *attributes[1];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -157,12 +160,12 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP3, x),
|
||||
3,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
attributes[1] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
1);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -172,7 +175,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2C4), data);
|
||||
CoglAttribute *attributes[3];
|
||||
CoglAttribute *attributes[2];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -186,12 +189,12 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP2C4, r),
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
attributes[2] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
2);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -201,7 +204,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3C4), data);
|
||||
CoglAttribute *attributes[3];
|
||||
CoglAttribute *attributes[2];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -215,12 +218,12 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP3C4, r),
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
attributes[2] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
2);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -230,7 +233,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2), data);
|
||||
CoglAttribute *attributes[3];
|
||||
CoglAttribute *attributes[2];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -244,12 +247,12 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP2T2, s),
|
||||
2,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
attributes[2] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
2);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -259,7 +262,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2), data);
|
||||
CoglAttribute *attributes[3];
|
||||
CoglAttribute *attributes[2];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -273,12 +276,12 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP3T2, s),
|
||||
2,
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
attributes[2] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
2);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -288,7 +291,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2C4), data);
|
||||
CoglAttribute *attributes[4];
|
||||
CoglAttribute *attributes[3];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -308,12 +311,12 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP2T2C4, r),
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
attributes[3] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
3);
|
||||
}
|
||||
|
||||
CoglPrimitive *
|
||||
@ -323,7 +326,7 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
|
||||
{
|
||||
CoglAttributeBuffer *attribute_buffer =
|
||||
cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2C4), data);
|
||||
CoglAttribute *attributes[4];
|
||||
CoglAttribute *attributes[3];
|
||||
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
"cogl_position_in",
|
||||
@ -343,12 +346,12 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
|
||||
offsetof (CoglVertexP3T2C4, r),
|
||||
4,
|
||||
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
|
||||
attributes[3] = NULL;
|
||||
|
||||
cogl_object_unref (attribute_buffer);
|
||||
|
||||
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
|
||||
attributes);
|
||||
return _cogl_primitive_new_with_attributes_unref (mode, n_vertices,
|
||||
attributes,
|
||||
3);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -389,7 +392,8 @@ warn_about_midscene_changes (void)
|
||||
|
||||
void
|
||||
cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
||||
CoglAttribute **attributes)
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -404,7 +408,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
||||
free_attributes_list (primitive);
|
||||
|
||||
g_array_set_size (primitive->attributes, 0);
|
||||
for (i = 0; attributes[i]; i++)
|
||||
for (i = 0; i < n_attributes; i++)
|
||||
{
|
||||
cogl_object_ref (attributes[i]);
|
||||
g_return_if_fail (cogl_is_attribute (attributes[i]));
|
||||
@ -539,15 +543,17 @@ cogl_primitive_draw (CoglPrimitive *primitive)
|
||||
(CoglAttribute **)primitive->attributes->data;
|
||||
|
||||
if (primitive->indices)
|
||||
cogl_draw_indexed_attributes_array (primitive->mode,
|
||||
primitive->first_vertex,
|
||||
primitive->n_vertices,
|
||||
primitive->indices,
|
||||
attributes);
|
||||
cogl_draw_indexed_attributes (primitive->mode,
|
||||
primitive->first_vertex,
|
||||
primitive->n_vertices,
|
||||
primitive->indices,
|
||||
attributes,
|
||||
primitive->attributes->len);
|
||||
else
|
||||
cogl_draw_attributes_array (primitive->mode,
|
||||
primitive->first_vertex,
|
||||
primitive->n_vertices,
|
||||
attributes);
|
||||
cogl_draw_attributes (primitive->mode,
|
||||
primitive->first_vertex,
|
||||
primitive->n_vertices,
|
||||
attributes,
|
||||
primitive->attributes->len);
|
||||
}
|
||||
|
||||
|
@ -231,11 +231,11 @@ cogl_primitive_new (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
...);
|
||||
|
||||
/* XXX: how about just: cogl_primitive_new_with_attributes () ? */
|
||||
CoglPrimitive *
|
||||
cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes);
|
||||
cogl_primitive_new_with_attributes (CoglVerticesMode mode,
|
||||
int n_vertices,
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes);
|
||||
|
||||
/**
|
||||
* cogl_primitive_new_p2:
|
||||
@ -634,7 +634,8 @@ cogl_primitive_set_mode (CoglPrimitive *primitive,
|
||||
*/
|
||||
void
|
||||
cogl_primitive_set_attributes (CoglPrimitive *primitive,
|
||||
CoglAttribute **attributes);
|
||||
CoglAttribute **attributes,
|
||||
int n_attributes);
|
||||
|
||||
|
||||
void
|
||||
|
@ -934,7 +934,7 @@ _cogl_rectangle_immediate (float x_1,
|
||||
x_2, y_2
|
||||
};
|
||||
CoglAttributeBuffer *attribute_buffer;
|
||||
CoglAttribute *attributes[2];
|
||||
CoglAttribute *attributes[1];
|
||||
|
||||
attribute_buffer = cogl_attribute_buffer_new (sizeof (vertices), vertices);
|
||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||
@ -943,15 +943,15 @@ _cogl_rectangle_immediate (float x_1,
|
||||
0, /* offset */
|
||||
2, /* n_components */
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
attributes[1] = NULL;
|
||||
|
||||
_cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
||||
0, /* first_index */
|
||||
4, /* n_vertices */
|
||||
attributes,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
|
||||
_cogl_draw_attributes (COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
||||
0, /* first_index */
|
||||
4, /* n_vertices */
|
||||
attributes,
|
||||
1,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
|
||||
|
||||
|
||||
cogl_object_unref (attributes[0]);
|
||||
@ -1067,8 +1067,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
||||
n_layers = cogl_pipeline_get_n_layers (pipeline);
|
||||
|
||||
n_attributes = 1 + n_layers + (use_color ? 1 : 0);
|
||||
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
|
||||
attributes[n_attributes] = NULL;
|
||||
attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes);
|
||||
|
||||
/* Our data is arranged like:
|
||||
* [X, Y, Z, TX0, TY0, TX1, TY1..., R, G, B, A,...] */
|
||||
@ -1167,9 +1166,10 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
||||
|
||||
cogl_push_source (pipeline);
|
||||
|
||||
cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
||||
0, n_vertices,
|
||||
attributes);
|
||||
cogl_draw_attributes (COGL_VERTICES_MODE_TRIANGLE_FAN,
|
||||
0, n_vertices,
|
||||
attributes,
|
||||
n_attributes);
|
||||
|
||||
cogl_pop_source ();
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
|
||||
|
||||
g_return_if_fail (n_attributes > 0);
|
||||
|
||||
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
|
||||
attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes);
|
||||
|
||||
i = 0;
|
||||
for (l = buffer->submitted_vbos; l; l = l->next)
|
||||
@ -1195,9 +1195,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
attributes[i] = NULL;
|
||||
|
||||
cogl_primitive_set_attributes (buffer->primitive, attributes);
|
||||
cogl_primitive_set_attributes (buffer->primitive, attributes, i);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -238,10 +238,10 @@ _cogl_path_stroke_nodes (CoglPath *path)
|
||||
{
|
||||
node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
|
||||
|
||||
cogl_draw_attributes (COGL_VERTICES_MODE_LINE_STRIP,
|
||||
0, node->path_size,
|
||||
data->stroke_attributes[path_num],
|
||||
NULL);
|
||||
cogl_vdraw_attributes (COGL_VERTICES_MODE_LINE_STRIP,
|
||||
0, node->path_size,
|
||||
data->stroke_attributes[path_num],
|
||||
NULL);
|
||||
|
||||
path_num++;
|
||||
}
|
||||
@ -343,15 +343,15 @@ _cogl_path_fill_nodes (CoglPath *path)
|
||||
|
||||
_cogl_path_build_fill_attribute_buffer (path);
|
||||
|
||||
_cogl_draw_indexed_attributes_array
|
||||
(COGL_VERTICES_MODE_TRIANGLES,
|
||||
0, /* first_vertex */
|
||||
path->data->fill_vbo_n_indices,
|
||||
path->data->fill_vbo_indices,
|
||||
path->data->fill_attributes,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
|
||||
_cogl_draw_indexed_attributes (COGL_VERTICES_MODE_TRIANGLES,
|
||||
0, /* first_vertex */
|
||||
path->data->fill_vbo_n_indices,
|
||||
path->data->fill_vbo_indices,
|
||||
path->data->fill_attributes,
|
||||
COGL_PATH_N_ATTRIBUTES,
|
||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||
COGL_DRAW_SKIP_PIPELINE_VALIDATION |
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1500,8 +1500,6 @@ _cogl_path_build_fill_attribute_buffer (CoglPath *path)
|
||||
G_STRUCT_OFFSET (CoglPathTesselatorVertex, s),
|
||||
2, /* n_components */
|
||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||
/* NULL terminator */
|
||||
data->fill_attributes[2] = NULL;
|
||||
|
||||
data->fill_vbo_indices = cogl_indices_new (tess.indices_type,
|
||||
tess.indices->data,
|
||||
|
Loading…
Reference in New Issue
Block a user