2010-10-12 11:53:10 +00:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2010-10-12 11:53:10 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Intel Corporation.
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2010-10-12 11:53:10 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2010-10-12 11:53:10 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-10-12 11:53:10 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-10-13 21:34:30 +00:00
|
|
|
#include "cogl-util.h"
|
2010-11-04 22:25:52 +00:00
|
|
|
#include "cogl-context-private.h"
|
2010-10-12 11:53:10 +00:00
|
|
|
#include "cogl-object-private.h"
|
|
|
|
#include "cogl-journal-private.h"
|
2011-01-20 19:31:53 +00:00
|
|
|
#include "cogl-attribute.h"
|
|
|
|
#include "cogl-attribute-private.h"
|
2010-10-27 17:54:57 +00:00
|
|
|
#include "cogl-pipeline.h"
|
|
|
|
#include "cogl-pipeline-private.h"
|
|
|
|
#include "cogl-pipeline-opengl-private.h"
|
2010-10-12 11:53:10 +00:00
|
|
|
#include "cogl-texture-private.h"
|
|
|
|
#include "cogl-framebuffer-private.h"
|
|
|
|
#include "cogl-indices-private.h"
|
2011-12-07 12:19:58 +00:00
|
|
|
#ifdef COGL_PIPELINE_PROGEND_GLSL
|
2010-12-03 17:46:16 +00:00
|
|
|
#include "cogl-pipeline-progend-glsl-private.h"
|
|
|
|
#endif
|
2011-09-14 11:17:09 +00:00
|
|
|
#include "cogl-private.h"
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2011-09-20 18:56:55 +00:00
|
|
|
#include <stdlib.h>
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
/* This isn't defined in the GLES headers */
|
|
|
|
#ifndef GL_UNSIGNED_INT
|
|
|
|
#define GL_UNSIGNED_INT 0x1405
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
static void _cogl_attribute_free (CoglAttribute *attribute);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
COGL_OBJECT_DEFINE (Attribute, attribute);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
static CoglBool
|
2011-11-24 18:09:53 +00:00
|
|
|
validate_cogl_attribute_name (const char *name,
|
2012-02-22 15:51:57 +00:00
|
|
|
char **real_attribute_name,
|
2011-11-24 18:09:53 +00:00
|
|
|
CoglAttributeNameID *name_id,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool *normalized,
|
2012-09-27 10:06:16 +00:00
|
|
|
int *layer_number)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
|
|
|
name = name + 5; /* skip "cogl_" */
|
|
|
|
|
|
|
|
*normalized = FALSE;
|
2012-09-27 10:06:16 +00:00
|
|
|
*layer_number = 0;
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
if (strcmp (name, "position_in") == 0)
|
2011-11-24 18:09:53 +00:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY;
|
2010-10-12 11:53:10 +00:00
|
|
|
else if (strcmp (name, "color_in") == 0)
|
|
|
|
{
|
2011-01-20 19:31:53 +00:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY;
|
2011-11-24 18:09:53 +00:00
|
|
|
*normalized = TRUE;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
else if (strcmp (name, "tex_coord_in") == 0)
|
2012-02-22 15:51:57 +00:00
|
|
|
{
|
|
|
|
*real_attribute_name = "cogl_tex_coord0_in";
|
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
|
|
|
}
|
2010-10-12 11:53:10 +00:00
|
|
|
else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0)
|
|
|
|
{
|
2011-09-20 18:56:55 +00:00
|
|
|
char *endptr;
|
2012-09-27 10:06:16 +00:00
|
|
|
*layer_number = strtoul (name + 9, &endptr, 10);
|
2011-09-20 18:56:55 +00:00
|
|
|
if (strcmp (endptr, "_in") != 0)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
|
|
|
g_warning ("Texture coordinate attributes should either be named "
|
2012-02-22 15:51:57 +00:00
|
|
|
"\"cogl_tex_coord_in\" or named with a texture unit index "
|
2010-10-12 11:53:10 +00:00
|
|
|
"like \"cogl_tex_coord2_in\"\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-01-20 19:31:53 +00:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
2010-12-22 01:45:09 +00:00
|
|
|
else if (strcmp (name, "normal_in") == 0)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2011-01-20 19:31:53 +00:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY;
|
2010-10-12 11:53:10 +00:00
|
|
|
*normalized = TRUE;
|
|
|
|
}
|
2012-11-08 16:56:02 +00:00
|
|
|
else if (strcmp (name, "point_size_in") == 0)
|
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_POINT_SIZE_ARRAY;
|
2010-10-12 11:53:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Unknown cogl_* attribute name cogl_%s\n", name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-24 18:09:53 +00:00
|
|
|
CoglAttributeNameState *
|
|
|
|
_cogl_attribute_register_attribute_name (CoglContext *context,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
CoglAttributeNameState *name_state = g_new (CoglAttributeNameState, 1);
|
|
|
|
int name_index = context->n_attribute_names++;
|
2012-02-22 15:51:57 +00:00
|
|
|
char *name_copy = g_strdup (name);
|
2011-11-24 18:09:53 +00:00
|
|
|
|
2012-02-22 15:51:57 +00:00
|
|
|
name_state->name = NULL;
|
2011-11-24 18:09:53 +00:00
|
|
|
name_state->name_index = name_index;
|
|
|
|
if (strncmp (name, "cogl_", 5) == 0)
|
|
|
|
{
|
|
|
|
if (!validate_cogl_attribute_name (name,
|
2012-02-22 15:51:57 +00:00
|
|
|
&name_state->name,
|
2011-11-24 18:09:53 +00:00
|
|
|
&name_state->name_id,
|
|
|
|
&name_state->normalized_default,
|
2012-09-27 10:06:16 +00:00
|
|
|
&name_state->layer_number))
|
2012-02-22 15:51:57 +00:00
|
|
|
goto error;
|
2011-11-24 18:09:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name_state->name_id = COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY;
|
|
|
|
name_state->normalized_default = FALSE;
|
2012-09-27 10:06:16 +00:00
|
|
|
name_state->layer_number = 0;
|
2011-11-24 18:09:53 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 15:51:57 +00:00
|
|
|
if (name_state->name == NULL)
|
|
|
|
name_state->name = name_copy;
|
|
|
|
|
2011-11-24 18:09:53 +00:00
|
|
|
g_hash_table_insert (context->attribute_name_states_hash,
|
2012-02-22 15:51:57 +00:00
|
|
|
name_copy, name_state);
|
2011-11-24 18:09:53 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (context->attribute_name_index_map == NULL))
|
|
|
|
context->attribute_name_index_map =
|
|
|
|
g_array_new (FALSE, FALSE, sizeof (void *));
|
|
|
|
|
|
|
|
g_array_set_size (context->attribute_name_index_map, name_index + 1);
|
|
|
|
|
|
|
|
g_array_index (context->attribute_name_index_map,
|
|
|
|
CoglAttributeNameState *, name_index) = name_state;
|
|
|
|
|
|
|
|
return name_state;
|
|
|
|
|
|
|
|
error:
|
|
|
|
g_free (name_state);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-08-06 20:19:27 +00:00
|
|
|
static CoglBool
|
|
|
|
validate_n_components (const CoglAttributeNameState *name_state,
|
|
|
|
int n_components)
|
|
|
|
{
|
|
|
|
switch (name_state->name_id)
|
|
|
|
{
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
|
|
|
if (G_UNLIKELY (n_components == 1))
|
|
|
|
{
|
|
|
|
g_critical ("glVertexPointer doesn't allow 1 component vertex "
|
|
|
|
"positions so we currently only support \"cogl_vertex\" "
|
|
|
|
"attributes where n_components == 2, 3 or 4");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
|
|
|
if (G_UNLIKELY (n_components != 3 && n_components != 4))
|
|
|
|
{
|
|
|
|
g_critical ("glColorPointer expects 3 or 4 component colors so we "
|
|
|
|
"currently only support \"cogl_color\" attributes where "
|
|
|
|
"n_components == 3 or 4");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
|
|
|
if (G_UNLIKELY (n_components != 3))
|
|
|
|
{
|
|
|
|
g_critical ("glNormalPointer expects 3 component normals so we "
|
|
|
|
"currently only support \"cogl_normal\" attributes "
|
|
|
|
"where n_components == 3");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-08 16:56:02 +00:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_POINT_SIZE_ARRAY:
|
|
|
|
if (G_UNLIKELY (n_components != 1))
|
|
|
|
{
|
|
|
|
g_critical ("The point size attribute can only have one "
|
|
|
|
"component");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2012-08-06 20:19:27 +00:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
CoglAttribute *
|
2011-03-02 15:01:41 +00:00
|
|
|
cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
2011-01-20 19:31:53 +00:00
|
|
|
const char *name,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
size_t stride,
|
|
|
|
size_t offset,
|
2011-01-20 19:31:53 +00:00
|
|
|
int n_components,
|
|
|
|
CoglAttributeType type)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2011-01-20 19:31:53 +00:00
|
|
|
CoglAttribute *attribute = g_slice_new (CoglAttribute);
|
2012-08-06 20:19:27 +00:00
|
|
|
CoglBuffer *buffer = COGL_BUFFER (attribute_buffer);
|
|
|
|
CoglContext *ctx = buffer->context;
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2012-08-06 20:19:27 +00:00
|
|
|
attribute->is_buffered = TRUE;
|
2011-11-24 18:09:53 +00:00
|
|
|
|
|
|
|
attribute->name_state =
|
|
|
|
g_hash_table_lookup (ctx->attribute_name_states_hash, name);
|
|
|
|
if (!attribute->name_state)
|
|
|
|
{
|
|
|
|
CoglAttributeNameState *name_state =
|
|
|
|
_cogl_attribute_register_attribute_name (ctx, name);
|
|
|
|
if (!name_state)
|
|
|
|
goto error;
|
|
|
|
attribute->name_state = name_state;
|
|
|
|
}
|
2012-08-06 20:19:27 +00:00
|
|
|
|
|
|
|
attribute->d.buffered.attribute_buffer = cogl_object_ref (attribute_buffer);
|
|
|
|
attribute->d.buffered.stride = stride;
|
|
|
|
attribute->d.buffered.offset = offset;
|
|
|
|
attribute->d.buffered.n_components = n_components;
|
|
|
|
attribute->d.buffered.type = type;
|
|
|
|
|
2010-10-12 11:53:10 +00:00
|
|
|
attribute->immutable_ref = 0;
|
|
|
|
|
2011-11-24 18:09:53 +00:00
|
|
|
if (attribute->name_state->name_id != COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
|
2011-09-19 01:31:41 +00:00
|
|
|
{
|
2012-08-06 20:19:27 +00:00
|
|
|
if (!validate_n_components (attribute->name_state, n_components))
|
|
|
|
return NULL;
|
|
|
|
attribute->normalized =
|
|
|
|
attribute->name_state->normalized_default;
|
2011-09-19 01:31:41 +00:00
|
|
|
}
|
2010-10-12 11:53:10 +00:00
|
|
|
else
|
2011-11-24 18:09:53 +00:00
|
|
|
attribute->normalized = FALSE;
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
return _cogl_attribute_object_new (attribute);
|
2011-11-24 18:09:53 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
_cogl_attribute_free (attribute);
|
|
|
|
return NULL;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 20:19:27 +00:00
|
|
|
static CoglAttribute *
|
|
|
|
_cogl_attribute_new_const (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
int n_components,
|
|
|
|
int n_columns,
|
|
|
|
CoglBool transpose,
|
|
|
|
const float *value)
|
|
|
|
{
|
|
|
|
CoglAttribute *attribute = g_slice_new (CoglAttribute);
|
|
|
|
|
|
|
|
attribute->name_state =
|
|
|
|
g_hash_table_lookup (context->attribute_name_states_hash, name);
|
|
|
|
if (!attribute->name_state)
|
|
|
|
{
|
|
|
|
CoglAttributeNameState *name_state =
|
|
|
|
_cogl_attribute_register_attribute_name (context, name);
|
|
|
|
if (!name_state)
|
|
|
|
goto error;
|
|
|
|
attribute->name_state = name_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validate_n_components (attribute->name_state, n_components))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
attribute->is_buffered = FALSE;
|
|
|
|
attribute->normalized = FALSE;
|
|
|
|
|
|
|
|
attribute->d.constant.context = cogl_object_ref (context);
|
|
|
|
|
|
|
|
attribute->d.constant.boxed.v.array = NULL;
|
|
|
|
|
|
|
|
if (n_columns == 1)
|
|
|
|
{
|
|
|
|
_cogl_boxed_value_set_float (&attribute->d.constant.boxed,
|
|
|
|
n_components,
|
|
|
|
1,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: Up until GL[ES] 3 only square matrices were supported
|
|
|
|
* and we don't currently expose non-square matrices in Cogl.
|
|
|
|
*/
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (n_columns == n_components, NULL);
|
|
|
|
_cogl_boxed_value_set_matrix (&attribute->d.constant.boxed,
|
|
|
|
n_columns,
|
|
|
|
1,
|
|
|
|
transpose,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _cogl_attribute_object_new (attribute);
|
|
|
|
|
|
|
|
error:
|
|
|
|
_cogl_attribute_free (attribute);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_1f (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
float value)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
1, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_2fv (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
const float *value)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
2, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_3fv (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
const float *value)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
3, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_4fv (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
const float *value)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
4, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_2f (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
float component0,
|
|
|
|
float component1)
|
|
|
|
{
|
|
|
|
float vec2[2] = { component0, component1 };
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
2, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
vec2);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_3f (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
float component0,
|
|
|
|
float component1,
|
|
|
|
float component2)
|
|
|
|
{
|
|
|
|
float vec3[3] = { component0, component1, component2 };
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
3, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
vec3);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_4f (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
float component0,
|
|
|
|
float component1,
|
|
|
|
float component2,
|
|
|
|
float component3)
|
|
|
|
{
|
|
|
|
float vec4[4] = { component0, component1, component2, component3 };
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
4, /* n_components */
|
|
|
|
1, /* 1 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
vec4);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_2x2fv (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
const float *matrix2x2,
|
|
|
|
CoglBool transpose)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
2, /* n_components */
|
|
|
|
2, /* 2 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
matrix2x2);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_3x3fv (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
const float *matrix3x3,
|
|
|
|
CoglBool transpose)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
3, /* n_components */
|
|
|
|
3, /* 3 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
matrix3x3);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAttribute *
|
|
|
|
cogl_attribute_new_const_4x4fv (CoglContext *context,
|
|
|
|
const char *name,
|
|
|
|
const float *matrix4x4,
|
|
|
|
CoglBool transpose)
|
|
|
|
{
|
|
|
|
return _cogl_attribute_new_const (context,
|
|
|
|
name,
|
|
|
|
4, /* n_components */
|
|
|
|
4, /* 4 column vector */
|
|
|
|
FALSE, /* no transpose */
|
|
|
|
matrix4x4);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool
|
2011-01-20 19:31:53 +00:00
|
|
|
cogl_attribute_get_normalized (CoglAttribute *attribute)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), FALSE);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
return attribute->normalized;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
warn_about_midscene_changes (void)
|
|
|
|
{
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
static CoglBool seen = FALSE;
|
2010-10-12 11:53:10 +00:00
|
|
|
if (!seen)
|
|
|
|
{
|
|
|
|
g_warning ("Mid-scene modification of attributes has "
|
|
|
|
"undefined results\n");
|
|
|
|
seen = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-20 19:31:53 +00:00
|
|
|
cogl_attribute_set_normalized (CoglAttribute *attribute,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool normalized)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (attribute->immutable_ref))
|
|
|
|
warn_about_midscene_changes ();
|
|
|
|
|
|
|
|
attribute->normalized = normalized;
|
|
|
|
}
|
|
|
|
|
2011-03-02 15:01:41 +00:00
|
|
|
CoglAttributeBuffer *
|
|
|
|
cogl_attribute_get_buffer (CoglAttribute *attribute)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
|
2012-08-06 20:19:27 +00:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (attribute->is_buffered, NULL);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2012-08-06 20:19:27 +00:00
|
|
|
return attribute->d.buffered.attribute_buffer;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-03-02 23:31:19 +00:00
|
|
|
cogl_attribute_set_buffer (CoglAttribute *attribute,
|
|
|
|
CoglAttributeBuffer *attribute_buffer)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
|
2012-08-06 20:19:27 +00:00
|
|
|
_COGL_RETURN_IF_FAIL (attribute->is_buffered);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (attribute->immutable_ref))
|
|
|
|
warn_about_midscene_changes ();
|
|
|
|
|
2011-03-02 15:01:41 +00:00
|
|
|
cogl_object_ref (attribute_buffer);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2012-08-06 20:19:27 +00:00
|
|
|
cogl_object_unref (attribute->d.buffered.attribute_buffer);
|
|
|
|
attribute->d.buffered.attribute_buffer = attribute_buffer;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
CoglAttribute *
|
|
|
|
_cogl_attribute_immutable_ref (CoglAttribute *attribute)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2012-08-06 20:19:27 +00:00
|
|
|
CoglBuffer *buffer = COGL_BUFFER (attribute->d.buffered.attribute_buffer);
|
|
|
|
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
attribute->immutable_ref++;
|
2012-08-06 20:19:27 +00:00
|
|
|
_cogl_buffer_immutable_ref (buffer);
|
2011-01-20 19:31:53 +00:00
|
|
|
return attribute;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-20 19:31:53 +00:00
|
|
|
_cogl_attribute_immutable_unref (CoglAttribute *attribute)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2012-08-06 20:19:27 +00:00
|
|
|
CoglBuffer *buffer = COGL_BUFFER (attribute->d.buffered.attribute_buffer);
|
|
|
|
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
|
|
|
|
_COGL_RETURN_IF_FAIL (attribute->immutable_ref > 0);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
attribute->immutable_ref--;
|
2012-08-06 20:19:27 +00:00
|
|
|
_cogl_buffer_immutable_unref (buffer);
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-20 19:31:53 +00:00
|
|
|
_cogl_attribute_free (CoglAttribute *attribute)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2012-09-28 16:58:31 +00:00
|
|
|
if (attribute->is_buffered)
|
|
|
|
cogl_object_unref (attribute->d.buffered.attribute_buffer);
|
|
|
|
else
|
|
|
|
_cogl_boxed_value_destroy (&attribute->d.constant.boxed);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2011-01-20 19:31:53 +00:00
|
|
|
g_slice_free (CoglAttribute, attribute);
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
static CoglBool
|
2010-10-27 17:54:57 +00:00
|
|
|
validate_layer_cb (CoglPipeline *pipeline,
|
2010-10-12 11:53:10 +00:00
|
|
|
int layer_index,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2011-08-24 20:30:34 +00:00
|
|
|
CoglTexture *texture =
|
2012-02-05 20:04:14 +00:00
|
|
|
cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
2012-09-19 19:04:24 +00:00
|
|
|
CoglFlushLayerState *state = user_data;
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool status = TRUE;
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
/* invalid textures will be handled correctly in
|
2010-10-27 17:54:57 +00:00
|
|
|
* _cogl_pipeline_flush_layers_gl_state */
|
2011-08-24 20:30:34 +00:00
|
|
|
if (texture == NULL)
|
2010-10-12 11:53:10 +00:00
|
|
|
goto validated;
|
|
|
|
|
2011-01-06 13:25:45 +00:00
|
|
|
_cogl_texture_flush_journal_rendering (texture);
|
|
|
|
|
2010-10-12 11:53:10 +00:00
|
|
|
/* Give the texture a chance to know that we're rendering
|
|
|
|
non-quad shaped primitives. If the texture is in an atlas it
|
|
|
|
will be migrated */
|
|
|
|
_cogl_texture_ensure_non_quad_rendering (texture);
|
|
|
|
|
|
|
|
/* We need to ensure the mipmaps are ready before deciding
|
|
|
|
* anything else about the texture because the texture storate
|
|
|
|
* could completely change if it needs to be migrated out of the
|
|
|
|
* atlas and will affect how we validate the layer.
|
|
|
|
*/
|
2010-10-27 17:54:57 +00:00
|
|
|
_cogl_pipeline_pre_paint_for_layer (pipeline, layer_index);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
|
|
|
if (!_cogl_texture_can_hardware_repeat (texture))
|
|
|
|
{
|
|
|
|
g_warning ("Disabling layer %d of the current source material, "
|
|
|
|
"because texturing with the vertex buffer API is not "
|
|
|
|
"currently supported using sliced textures, or textures "
|
|
|
|
"with waste\n", layer_index);
|
|
|
|
|
|
|
|
/* XXX: maybe we can add a mechanism for users to forcibly use
|
|
|
|
* textures with waste where it would be their responsability to use
|
|
|
|
* texture coords in the range [0,1] such that sampling outside isn't
|
|
|
|
* required. We can then use a texture matrix (or a modification of
|
|
|
|
* the users own matrix) to map 1 to the edge of the texture data.
|
|
|
|
*
|
|
|
|
* Potentially, given the same guarantee as above we could also
|
|
|
|
* support a single sliced layer too. We would have to redraw the
|
|
|
|
* vertices once for each layer, each time with a fiddled texture
|
|
|
|
* matrix.
|
|
|
|
*/
|
|
|
|
state->fallback_layers |= (1 << state->unit);
|
2010-10-27 17:54:57 +00:00
|
|
|
state->options.flags |= COGL_PIPELINE_FLUSH_FALLBACK_MASK;
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
validated:
|
|
|
|
state->unit++;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2012-01-08 02:59:04 +00:00
|
|
|
void
|
|
|
|
_cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
|
|
|
|
CoglPipeline *pipeline,
|
|
|
|
CoglDrawFlags flags,
|
|
|
|
CoglAttribute **attributes,
|
|
|
|
int n_attributes)
|
2010-10-12 11:53:10 +00:00
|
|
|
{
|
2012-01-08 02:59:04 +00:00
|
|
|
CoglContext *ctx = framebuffer->context;
|
2012-09-19 19:04:24 +00:00
|
|
|
CoglFlushLayerState layers_state;
|
2012-09-19 21:32:25 +00:00
|
|
|
CoglPipeline *copy = NULL;
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2011-11-24 18:09:53 +00:00
|
|
|
if (!(flags & COGL_DRAW_SKIP_JOURNAL_FLUSH))
|
2012-03-16 17:26:30 +00:00
|
|
|
_cogl_journal_flush (framebuffer->journal);
|
2011-11-24 18:09:53 +00:00
|
|
|
|
2012-01-08 02:59:04 +00:00
|
|
|
layers_state.unit = 0;
|
|
|
|
layers_state.options.flags = 0;
|
|
|
|
layers_state.fallback_layers = 0;
|
2011-11-24 18:09:53 +00:00
|
|
|
|
|
|
|
if (!(flags & COGL_DRAW_SKIP_PIPELINE_VALIDATION))
|
2012-01-08 02:59:04 +00:00
|
|
|
cogl_pipeline_foreach_layer (pipeline,
|
2011-11-24 18:09:53 +00:00
|
|
|
validate_layer_cb,
|
2012-01-08 02:59:04 +00:00
|
|
|
&layers_state);
|
2011-11-24 18:09:53 +00:00
|
|
|
|
|
|
|
/* NB: _cogl_framebuffer_flush_state may disrupt various state (such
|
|
|
|
* as the pipeline state) when flushing the clip stack, so should
|
|
|
|
* always be done first when preparing to draw. We need to do this
|
|
|
|
* before setting up the array pointers because setting up the clip
|
|
|
|
* stack can cause some drawing which would change the array
|
|
|
|
* pointers. */
|
|
|
|
if (!(flags & COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH))
|
2012-01-08 02:59:04 +00:00
|
|
|
_cogl_framebuffer_flush_state (framebuffer,
|
|
|
|
framebuffer,
|
2011-11-24 18:09:53 +00:00
|
|
|
COGL_FRAMEBUFFER_STATE_ALL);
|
|
|
|
|
2011-01-12 22:12:41 +00:00
|
|
|
/* In cogl_read_pixels we have a fast-path when reading a single
|
|
|
|
* pixel and the scene is just comprised of simple rectangles still
|
|
|
|
* in the journal. For this optimization to work we need to track
|
|
|
|
* when the framebuffer really does get drawn to. */
|
2013-05-29 15:59:27 +00:00
|
|
|
_cogl_framebuffer_mark_mid_scene (framebuffer);
|
2013-11-29 21:16:37 +00:00
|
|
|
_cogl_framebuffer_mark_clear_clip_dirty (framebuffer);
|
2011-01-12 22:12:41 +00:00
|
|
|
|
2012-01-08 02:59:04 +00:00
|
|
|
if (G_UNLIKELY (!(flags & COGL_DRAW_SKIP_LEGACY_STATE)) &&
|
|
|
|
G_UNLIKELY (ctx->legacy_state_set) &&
|
2011-09-14 11:17:09 +00:00
|
|
|
_cogl_get_enable_legacy_state ())
|
2010-12-03 17:46:16 +00:00
|
|
|
{
|
2012-09-19 21:32:25 +00:00
|
|
|
copy = cogl_pipeline_copy (pipeline);
|
|
|
|
pipeline = copy;
|
2012-01-08 02:59:04 +00:00
|
|
|
_cogl_pipeline_apply_legacy_state (pipeline);
|
2010-12-03 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
2012-09-19 19:04:24 +00:00
|
|
|
ctx->driver_vtable->flush_attributes_state (framebuffer,
|
|
|
|
pipeline,
|
|
|
|
&layers_state,
|
|
|
|
flags,
|
|
|
|
attributes,
|
|
|
|
n_attributes);
|
2010-10-12 11:53:10 +00:00
|
|
|
|
2012-01-08 02:59:04 +00:00
|
|
|
if (copy)
|
|
|
|
cogl_object_unref (copy);
|
2010-10-12 11:53:10 +00:00
|
|
|
}
|
2013-05-16 14:19:30 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
_cogl_attribute_get_n_components (CoglAttribute *attribute)
|
|
|
|
{
|
|
|
|
if (attribute->is_buffered)
|
|
|
|
return attribute->d.buffered.n_components;
|
|
|
|
else
|
|
|
|
return attribute->d.constant.boxed.size;
|
|
|
|
}
|