2010-10-12 07:53:10 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Intel Corporation.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-10-13 17:34:30 -04:00
|
|
|
#include "cogl-util.h"
|
2010-11-04 18:25:52 -04:00
|
|
|
#include "cogl-context-private.h"
|
2010-10-12 07:53:10 -04:00
|
|
|
#include "cogl-object-private.h"
|
|
|
|
#include "cogl-journal-private.h"
|
2011-01-20 14:31:53 -05:00
|
|
|
#include "cogl-attribute.h"
|
|
|
|
#include "cogl-attribute-private.h"
|
2010-10-27 13:54:57 -04:00
|
|
|
#include "cogl-pipeline.h"
|
|
|
|
#include "cogl-pipeline-private.h"
|
|
|
|
#include "cogl-pipeline-opengl-private.h"
|
2010-10-12 07:53:10 -04:00
|
|
|
#include "cogl-texture-private.h"
|
|
|
|
#include "cogl-framebuffer-private.h"
|
|
|
|
#include "cogl-indices-private.h"
|
2011-12-07 07:19:58 -05:00
|
|
|
#ifdef COGL_PIPELINE_PROGEND_GLSL
|
2010-12-03 12:46:16 -05:00
|
|
|
#include "cogl-pipeline-progend-glsl-private.h"
|
|
|
|
#endif
|
2011-09-14 07:17:09 -04:00
|
|
|
#include "cogl-private.h"
|
2010-10-12 07:53:10 -04:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2011-09-20 14:56:55 -04:00
|
|
|
#include <stdlib.h>
|
2010-10-12 07:53:10 -04:00
|
|
|
|
|
|
|
/* This isn't defined in the GLES headers */
|
|
|
|
#ifndef GL_UNSIGNED_INT
|
|
|
|
#define GL_UNSIGNED_INT 0x1405
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
static void _cogl_attribute_free (CoglAttribute *attribute);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
COGL_OBJECT_DEFINE (Attribute, attribute);
|
2010-10-12 07:53:10 -04: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 16:56:40 -04:00
|
|
|
static CoglBool
|
2011-11-24 13:09:53 -05:00
|
|
|
validate_cogl_attribute_name (const char *name,
|
2012-02-22 10:51:57 -05:00
|
|
|
char **real_attribute_name,
|
2011-11-24 13:09:53 -05: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 16:56:40 -04:00
|
|
|
CoglBool *normalized,
|
2011-11-24 13:09:53 -05:00
|
|
|
int *texture_unit)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
|
|
|
name = name + 5; /* skip "cogl_" */
|
|
|
|
|
|
|
|
*normalized = FALSE;
|
|
|
|
*texture_unit = 0;
|
|
|
|
|
|
|
|
if (strcmp (name, "position_in") == 0)
|
2011-11-24 13:09:53 -05:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY;
|
2010-10-12 07:53:10 -04:00
|
|
|
else if (strcmp (name, "color_in") == 0)
|
|
|
|
{
|
2011-01-20 14:31:53 -05:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY;
|
2011-11-24 13:09:53 -05:00
|
|
|
*normalized = TRUE;
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
else if (strcmp (name, "tex_coord_in") == 0)
|
2012-02-22 10:51:57 -05:00
|
|
|
{
|
|
|
|
*real_attribute_name = "cogl_tex_coord0_in";
|
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
|
|
|
}
|
2010-10-12 07:53:10 -04:00
|
|
|
else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0)
|
|
|
|
{
|
2011-09-20 14:56:55 -04:00
|
|
|
char *endptr;
|
|
|
|
*texture_unit = strtoul (name + 9, &endptr, 10);
|
|
|
|
if (strcmp (endptr, "_in") != 0)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
|
|
|
g_warning ("Texture coordinate attributes should either be named "
|
2012-02-22 10:51:57 -05:00
|
|
|
"\"cogl_tex_coord_in\" or named with a texture unit index "
|
2010-10-12 07:53:10 -04:00
|
|
|
"like \"cogl_tex_coord2_in\"\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-01-20 14:31:53 -05:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
2010-12-21 20:45:09 -05:00
|
|
|
else if (strcmp (name, "normal_in") == 0)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-01-20 14:31:53 -05:00
|
|
|
*name_id = COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY;
|
2010-10-12 07:53:10 -04:00
|
|
|
*normalized = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Unknown cogl_* attribute name cogl_%s\n", name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-24 13:09:53 -05: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 10:51:57 -05:00
|
|
|
char *name_copy = g_strdup (name);
|
2011-11-24 13:09:53 -05:00
|
|
|
|
2012-02-22 10:51:57 -05:00
|
|
|
name_state->name = NULL;
|
2011-11-24 13:09:53 -05:00
|
|
|
name_state->name_index = name_index;
|
|
|
|
if (strncmp (name, "cogl_", 5) == 0)
|
|
|
|
{
|
|
|
|
if (!validate_cogl_attribute_name (name,
|
2012-02-22 10:51:57 -05:00
|
|
|
&name_state->name,
|
2011-11-24 13:09:53 -05:00
|
|
|
&name_state->name_id,
|
|
|
|
&name_state->normalized_default,
|
|
|
|
&name_state->texture_unit))
|
2012-02-22 10:51:57 -05:00
|
|
|
goto error;
|
2011-11-24 13:09:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name_state->name_id = COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY;
|
|
|
|
name_state->normalized_default = FALSE;
|
|
|
|
name_state->texture_unit = 0;
|
|
|
|
}
|
|
|
|
|
2012-02-22 10:51:57 -05:00
|
|
|
if (name_state->name == NULL)
|
|
|
|
name_state->name = name_copy;
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
g_hash_table_insert (context->attribute_name_states_hash,
|
2012-02-22 10:51:57 -05:00
|
|
|
name_copy, name_state);
|
2011-11-24 13:09:53 -05: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;
|
|
|
|
}
|
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
CoglAttribute *
|
2011-03-02 10:01:41 -05:00
|
|
|
cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
|
2011-01-20 14:31:53 -05: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 16:56:40 -04:00
|
|
|
size_t stride,
|
|
|
|
size_t offset,
|
2011-01-20 14:31:53 -05:00
|
|
|
int n_components,
|
|
|
|
CoglAttributeType type)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-01-20 14:31:53 -05:00
|
|
|
CoglAttribute *attribute = g_slice_new (CoglAttribute);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
/* FIXME: retrieve the context from the buffer */
|
|
|
|
_COGL_GET_CONTEXT (ctx, NULL);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2011-03-02 10:01:41 -05:00
|
|
|
attribute->attribute_buffer = cogl_object_ref (attribute_buffer);
|
2010-10-12 07:53:10 -04:00
|
|
|
attribute->stride = stride;
|
|
|
|
attribute->offset = offset;
|
|
|
|
attribute->n_components = n_components;
|
|
|
|
attribute->type = type;
|
|
|
|
attribute->immutable_ref = 0;
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
if (attribute->name_state->name_id != COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
|
2011-09-18 21:31:41 -04:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
switch (attribute->name_state->name_id)
|
2011-09-18 21:31:41 -04:00
|
|
|
{
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
2011-11-24 13:09:53 -05:00
|
|
|
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;
|
|
|
|
}
|
2011-09-18 21:31:41 -04:00
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
2011-11-24 13:09:53 -05:00
|
|
|
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;
|
|
|
|
}
|
2011-09-18 21:31:41 -04:00
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
2011-11-24 13:09:53 -05:00
|
|
|
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;
|
|
|
|
}
|
2011-09-18 21:31:41 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warn_if_reached ();
|
|
|
|
}
|
2011-11-24 13:09:53 -05:00
|
|
|
attribute->normalized = attribute->name_state->normalized_default;
|
2011-09-18 21:31:41 -04:00
|
|
|
}
|
2010-10-12 07:53:10 -04:00
|
|
|
else
|
2011-11-24 13:09:53 -05:00
|
|
|
attribute->normalized = FALSE;
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
return _cogl_attribute_object_new (attribute);
|
2011-11-24 13:09:53 -05:00
|
|
|
|
|
|
|
error:
|
|
|
|
_cogl_attribute_free (attribute);
|
|
|
|
return NULL;
|
2010-10-12 07:53:10 -04: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 16:56:40 -04:00
|
|
|
CoglBool
|
2011-01-20 14:31:53 -05:00
|
|
|
cogl_attribute_get_normalized (CoglAttribute *attribute)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), FALSE);
|
2010-10-12 07:53:10 -04: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 16:56:40 -04:00
|
|
|
static CoglBool seen = FALSE;
|
2010-10-12 07:53:10 -04:00
|
|
|
if (!seen)
|
|
|
|
{
|
|
|
|
g_warning ("Mid-scene modification of attributes has "
|
|
|
|
"undefined results\n");
|
|
|
|
seen = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-20 14:31:53 -05: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 16:56:40 -04:00
|
|
|
CoglBool normalized)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
|
2010-10-12 07:53:10 -04:00
|
|
|
|
|
|
|
if (G_UNLIKELY (attribute->immutable_ref))
|
|
|
|
warn_about_midscene_changes ();
|
|
|
|
|
|
|
|
attribute->normalized = normalized;
|
|
|
|
}
|
|
|
|
|
2011-03-02 10:01:41 -05:00
|
|
|
CoglAttributeBuffer *
|
|
|
|
cogl_attribute_get_buffer (CoglAttribute *attribute)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-03-02 10:01:41 -05:00
|
|
|
return attribute->attribute_buffer;
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-03-02 18:31:19 -05:00
|
|
|
cogl_attribute_set_buffer (CoglAttribute *attribute,
|
|
|
|
CoglAttributeBuffer *attribute_buffer)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
|
2010-10-12 07:53:10 -04:00
|
|
|
|
|
|
|
if (G_UNLIKELY (attribute->immutable_ref))
|
|
|
|
warn_about_midscene_changes ();
|
|
|
|
|
2011-03-02 10:01:41 -05:00
|
|
|
cogl_object_ref (attribute_buffer);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-03-02 10:01:41 -05:00
|
|
|
cogl_object_unref (attribute->attribute_buffer);
|
|
|
|
attribute->attribute_buffer = attribute_buffer;
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
CoglAttribute *
|
|
|
|
_cogl_attribute_immutable_ref (CoglAttribute *attribute)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
attribute->immutable_ref++;
|
2011-03-02 10:01:41 -05:00
|
|
|
_cogl_buffer_immutable_ref (COGL_BUFFER (attribute->attribute_buffer));
|
2011-01-20 14:31:53 -05:00
|
|
|
return attribute;
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-01-20 14:31:53 -05:00
|
|
|
_cogl_attribute_immutable_unref (CoglAttribute *attribute)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute));
|
|
|
|
_COGL_RETURN_IF_FAIL (attribute->immutable_ref > 0);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
attribute->immutable_ref--;
|
2011-03-02 10:01:41 -05:00
|
|
|
_cogl_buffer_immutable_unref (COGL_BUFFER (attribute->attribute_buffer));
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-20 14:31:53 -05:00
|
|
|
_cogl_attribute_free (CoglAttribute *attribute)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-03-02 10:01:41 -05:00
|
|
|
cogl_object_unref (attribute->attribute_buffer);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
g_slice_free (CoglAttribute, attribute);
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int unit;
|
2010-10-27 13:54:57 -04:00
|
|
|
CoglPipelineFlushOptions options;
|
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 16:56:40 -04:00
|
|
|
uint32_t fallback_layers;
|
2010-10-12 07:53:10 -04:00
|
|
|
} ValidateLayerState;
|
|
|
|
|
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 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-10-27 13:54:57 -04:00
|
|
|
validate_layer_cb (CoglPipeline *pipeline,
|
2010-10-12 07:53:10 -04:00
|
|
|
int layer_index,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2011-08-24 16:30:34 -04:00
|
|
|
CoglTexture *texture =
|
2012-02-05 15:04:14 -05:00
|
|
|
cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
2010-10-12 07:53:10 -04:00
|
|
|
ValidateLayerState *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 16:56:40 -04:00
|
|
|
CoglBool status = TRUE;
|
2010-10-12 07:53:10 -04:00
|
|
|
|
|
|
|
/* invalid textures will be handled correctly in
|
2010-10-27 13:54:57 -04:00
|
|
|
* _cogl_pipeline_flush_layers_gl_state */
|
2011-08-24 16:30:34 -04:00
|
|
|
if (texture == NULL)
|
2010-10-12 07:53:10 -04:00
|
|
|
goto validated;
|
|
|
|
|
2011-01-06 08:25:45 -05:00
|
|
|
_cogl_texture_flush_journal_rendering (texture);
|
|
|
|
|
2010-10-12 07:53:10 -04: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 13:54:57 -04:00
|
|
|
_cogl_pipeline_pre_paint_for_layer (pipeline, layer_index);
|
2010-10-12 07:53:10 -04: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 13:54:57 -04:00
|
|
|
state->options.flags |= COGL_PIPELINE_FLUSH_FALLBACK_MASK;
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
validated:
|
|
|
|
state->unit++;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
typedef struct _ForeachChangedBitState
|
|
|
|
{
|
|
|
|
CoglContext *context;
|
|
|
|
const CoglBitmask *new_bits;
|
|
|
|
CoglPipeline *pipeline;
|
|
|
|
} ForeachChangedBitState;
|
|
|
|
|
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 16:56:40 -04:00
|
|
|
static CoglBool
|
2011-11-24 13:09:53 -05:00
|
|
|
toggle_builtin_attribute_enabled_cb (int bit_num, void *user_data)
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
ForeachChangedBitState *state = user_data;
|
|
|
|
CoglContext *context = state->context;
|
2010-12-03 12:46:16 -05:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (context->driver == COGL_DRIVER_GL ||
|
|
|
|
context->driver == COGL_DRIVER_GLES1,
|
|
|
|
FALSE);
|
2011-07-06 16:51:00 -04:00
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
|
2011-11-24 13:09:53 -05: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 16:56:40 -04:00
|
|
|
CoglBool enabled = _cogl_bitmask_get (state->new_bits, bit_num);
|
2011-11-24 13:09:53 -05:00
|
|
|
GLenum cap;
|
2010-12-03 12:46:16 -05:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
switch (bit_num)
|
|
|
|
{
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
|
|
|
cap = GL_COLOR_ARRAY;
|
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
|
|
|
cap = GL_VERTEX_ARRAY;
|
|
|
|
break;
|
|
|
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
|
|
|
cap = GL_NORMAL_ARRAY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (enabled)
|
|
|
|
GE (context, glEnableClientState (cap));
|
|
|
|
else
|
|
|
|
GE (context, glDisableClientState (cap));
|
|
|
|
}
|
2011-07-07 15:44:56 -04:00
|
|
|
#endif
|
2011-10-26 13:43:21 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2010-12-03 12:46:16 -05: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 16:56:40 -04:00
|
|
|
static CoglBool
|
2011-11-24 13:09:53 -05:00
|
|
|
toggle_texcood_attribute_enabled_cb (int bit_num, void *user_data)
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
ForeachChangedBitState *state = user_data;
|
|
|
|
CoglContext *context = state->context;
|
|
|
|
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (context->driver == COGL_DRIVER_GL ||
|
|
|
|
context->driver == COGL_DRIVER_GLES1,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
|
|
|
|
{
|
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 16:56:40 -04:00
|
|
|
CoglBool enabled = _cogl_bitmask_get (state->new_bits, bit_num);
|
2011-11-24 13:09:53 -05:00
|
|
|
|
|
|
|
GE( context, glClientActiveTexture (GL_TEXTURE0 + bit_num) );
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
|
GE( context, glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
|
|
|
|
else
|
|
|
|
GE( context, glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-12-03 12:46:16 -05: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 16:56:40 -04:00
|
|
|
static CoglBool
|
2011-11-24 13:09:53 -05:00
|
|
|
toggle_custom_attribute_enabled_cb (int bit_num, void *user_data)
|
|
|
|
{
|
|
|
|
ForeachChangedBitState *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 16:56:40 -04:00
|
|
|
CoglBool enabled = _cogl_bitmask_get (state->new_bits, bit_num);
|
2011-11-24 13:09:53 -05:00
|
|
|
CoglContext *context = state->context;
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
|
GE( context, glEnableVertexAttribArray (bit_num) );
|
|
|
|
else
|
|
|
|
GE( context, glDisableVertexAttribArray (bit_num) );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
foreach_changed_bit_and_save (CoglContext *context,
|
|
|
|
CoglBitmask *current_bits,
|
|
|
|
const CoglBitmask *new_bits,
|
|
|
|
CoglBitmaskForeachFunc callback,
|
|
|
|
ForeachChangedBitState *state)
|
|
|
|
{
|
2010-12-03 12:46:16 -05:00
|
|
|
/* Get the list of bits that are different */
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_clear_all (&context->changed_bits_tmp);
|
|
|
|
_cogl_bitmask_set_bits (&context->changed_bits_tmp, current_bits);
|
|
|
|
_cogl_bitmask_xor_bits (&context->changed_bits_tmp, new_bits);
|
2010-12-03 12:46:16 -05:00
|
|
|
|
|
|
|
/* Iterate over each bit to change */
|
2011-11-24 13:09:53 -05:00
|
|
|
state->new_bits = new_bits;
|
|
|
|
_cogl_bitmask_foreach (&context->changed_bits_tmp,
|
|
|
|
callback,
|
|
|
|
state);
|
2010-12-03 12:46:16 -05:00
|
|
|
|
|
|
|
/* Store the new values */
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_clear_all (current_bits);
|
|
|
|
_cogl_bitmask_set_bits (current_bits, new_bits);
|
|
|
|
}
|
|
|
|
|
2011-12-07 07:19:58 -05:00
|
|
|
#ifdef COGL_PIPELINE_PROGEND_GLSL
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
static void
|
|
|
|
setup_generic_attribute (CoglContext *context,
|
|
|
|
CoglPipeline *pipeline,
|
|
|
|
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 16:56:40 -04:00
|
|
|
uint8_t *base)
|
2011-11-24 13:09:53 -05:00
|
|
|
{
|
|
|
|
int name_index = attribute->name_state->name_index;
|
|
|
|
int attrib_location =
|
|
|
|
_cogl_pipeline_progend_glsl_get_attrib_location (pipeline, name_index);
|
|
|
|
if (attrib_location != -1)
|
|
|
|
{
|
|
|
|
GE( context, glVertexAttribPointer (attrib_location,
|
|
|
|
attribute->n_components,
|
|
|
|
attribute->type,
|
|
|
|
attribute->normalized,
|
|
|
|
attribute->stride,
|
|
|
|
base + attribute->offset) );
|
|
|
|
_cogl_bitmask_set (&context->enable_custom_attributes_tmp,
|
|
|
|
attrib_location, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-07 07:19:58 -05:00
|
|
|
#endif /* COGL_PIPELINE_PROGEND_GLSL */
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
static void
|
|
|
|
apply_attribute_enable_updates (CoglContext *context,
|
|
|
|
CoglPipeline *pipeline)
|
|
|
|
{
|
|
|
|
ForeachChangedBitState changed_bits_state;
|
|
|
|
|
|
|
|
changed_bits_state.context = context;
|
|
|
|
changed_bits_state.new_bits = &context->enable_builtin_attributes_tmp;
|
|
|
|
changed_bits_state.pipeline = pipeline;
|
|
|
|
|
|
|
|
foreach_changed_bit_and_save (context,
|
|
|
|
&context->enabled_builtin_attributes,
|
|
|
|
&context->enable_builtin_attributes_tmp,
|
|
|
|
toggle_builtin_attribute_enabled_cb,
|
|
|
|
&changed_bits_state);
|
|
|
|
|
|
|
|
changed_bits_state.new_bits = &context->enable_texcoord_attributes_tmp;
|
|
|
|
foreach_changed_bit_and_save (context,
|
|
|
|
&context->enabled_texcoord_attributes,
|
|
|
|
&context->enable_texcoord_attributes_tmp,
|
|
|
|
toggle_texcood_attribute_enabled_cb,
|
|
|
|
&changed_bits_state);
|
|
|
|
|
|
|
|
changed_bits_state.new_bits = &context->enable_custom_attributes_tmp;
|
|
|
|
foreach_changed_bit_and_save (context,
|
|
|
|
&context->enabled_custom_attributes,
|
|
|
|
&context->enable_custom_attributes_tmp,
|
|
|
|
toggle_custom_attribute_enabled_cb,
|
|
|
|
&changed_bits_state);
|
2010-12-03 12:46:16 -05:00
|
|
|
}
|
|
|
|
|
2012-01-07 21:59:04 -05:00
|
|
|
void
|
|
|
|
_cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
|
|
|
|
CoglPipeline *pipeline,
|
|
|
|
CoglDrawFlags flags,
|
|
|
|
CoglAttribute **attributes,
|
|
|
|
int n_attributes)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
|
|
|
int i;
|
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 16:56:40 -04:00
|
|
|
CoglBool skip_gl_color = FALSE;
|
2010-10-27 13:54:57 -04:00
|
|
|
CoglPipeline *copy = NULL;
|
2010-12-02 16:08:30 -05:00
|
|
|
int n_tex_coord_attribs = 0;
|
2012-01-07 21:59:04 -05:00
|
|
|
ValidateLayerState layers_state;
|
|
|
|
CoglContext *ctx = framebuffer->context;
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
if (!(flags & COGL_DRAW_SKIP_JOURNAL_FLUSH))
|
2012-03-16 13:26:30 -04:00
|
|
|
_cogl_journal_flush (framebuffer->journal);
|
2011-11-24 13:09:53 -05:00
|
|
|
|
2012-01-07 21:59:04 -05:00
|
|
|
layers_state.unit = 0;
|
|
|
|
layers_state.options.flags = 0;
|
|
|
|
layers_state.fallback_layers = 0;
|
2011-11-24 13:09:53 -05:00
|
|
|
|
|
|
|
if (!(flags & COGL_DRAW_SKIP_PIPELINE_VALIDATION))
|
2012-01-07 21:59:04 -05:00
|
|
|
cogl_pipeline_foreach_layer (pipeline,
|
2011-11-24 13:09:53 -05:00
|
|
|
validate_layer_cb,
|
2012-01-07 21:59:04 -05:00
|
|
|
&layers_state);
|
2011-11-24 13:09:53 -05: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-07 21:59:04 -05:00
|
|
|
_cogl_framebuffer_flush_state (framebuffer,
|
|
|
|
framebuffer,
|
2011-11-24 13:09:53 -05:00
|
|
|
COGL_FRAMEBUFFER_STATE_ALL);
|
|
|
|
|
2011-01-12 17:12:41 -05: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. */
|
|
|
|
_cogl_framebuffer_dirty (framebuffer);
|
|
|
|
|
2010-12-03 12:46:16 -05:00
|
|
|
/* 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. */
|
2011-03-02 20:02:12 -05:00
|
|
|
for (i = 0; i < n_attributes; i++)
|
2011-11-24 13:09:53 -05:00
|
|
|
switch (attributes[i]->name_state->name_id)
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
2010-12-14 09:44:45 -05:00
|
|
|
if ((flags & COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE) == 0 &&
|
2012-01-07 21:59:04 -05:00
|
|
|
!_cogl_pipeline_get_real_blend_enabled (pipeline))
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
|
|
|
CoglPipelineBlendEnable blend_enable =
|
|
|
|
COGL_PIPELINE_BLEND_ENABLE_ENABLED;
|
2012-01-07 21:59:04 -05:00
|
|
|
copy = cogl_pipeline_copy (pipeline);
|
2010-12-03 12:46:16 -05:00
|
|
|
_cogl_pipeline_set_blend_enabled (copy, blend_enable);
|
2012-01-07 21:59:04 -05:00
|
|
|
pipeline = copy;
|
2010-12-03 12:46:16 -05:00
|
|
|
}
|
|
|
|
skip_gl_color = TRUE;
|
|
|
|
break;
|
|
|
|
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
2010-12-03 12:46:16 -05:00
|
|
|
n_tex_coord_attribs++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-07 21:59:04 -05:00
|
|
|
if (G_UNLIKELY (layers_state.options.flags))
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
|
|
|
/* If we haven't already created a derived pipeline... */
|
|
|
|
if (!copy)
|
|
|
|
{
|
2012-01-07 21:59:04 -05:00
|
|
|
copy = cogl_pipeline_copy (pipeline);
|
|
|
|
pipeline = copy;
|
2010-12-03 12:46:16 -05:00
|
|
|
}
|
2012-01-07 21:59:04 -05:00
|
|
|
_cogl_pipeline_apply_overrides (pipeline, &layers_state.options);
|
2010-12-03 12:46:16 -05:00
|
|
|
|
|
|
|
/* TODO:
|
|
|
|
* overrides = cogl_pipeline_get_data (pipeline,
|
|
|
|
* last_overrides_key);
|
|
|
|
* if (overrides)
|
|
|
|
* {
|
|
|
|
* age = cogl_pipeline_get_age (pipeline);
|
|
|
|
* XXX: actually we also need to check for legacy_state
|
|
|
|
* and blending overrides for use of glColorPointer...
|
|
|
|
* if (overrides->ags != age ||
|
|
|
|
* memcmp (&overrides->options, &options,
|
|
|
|
* sizeof (options) != 0)
|
|
|
|
* {
|
|
|
|
* cogl_object_unref (overrides->weak_pipeline);
|
|
|
|
* g_slice_free (Overrides, overrides);
|
|
|
|
* overrides = NULL;
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* if (!overrides)
|
|
|
|
* {
|
|
|
|
* overrides = g_slice_new (Overrides);
|
|
|
|
* overrides->weak_pipeline =
|
2012-01-07 21:59:04 -05:00
|
|
|
* cogl_pipeline_weak_copy (pipeline);
|
2010-12-03 12:46:16 -05:00
|
|
|
* _cogl_pipeline_apply_overrides (overrides->weak_pipeline,
|
|
|
|
* &options);
|
|
|
|
*
|
|
|
|
* cogl_pipeline_set_data (pipeline, last_overrides_key,
|
|
|
|
* weak_overrides,
|
|
|
|
* free_overrides_cb,
|
|
|
|
* NULL);
|
|
|
|
* }
|
2012-01-07 21:59:04 -05:00
|
|
|
* pipeline = overrides->weak_pipeline;
|
2010-12-03 12:46:16 -05:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2012-01-07 21:59:04 -05:00
|
|
|
if (G_UNLIKELY (!(flags & COGL_DRAW_SKIP_LEGACY_STATE)) &&
|
|
|
|
G_UNLIKELY (ctx->legacy_state_set) &&
|
2011-09-14 07:17:09 -04:00
|
|
|
_cogl_get_enable_legacy_state ())
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
|
|
|
/* If we haven't already created a derived pipeline... */
|
|
|
|
if (!copy)
|
|
|
|
{
|
2012-01-07 21:59:04 -05:00
|
|
|
copy = cogl_pipeline_copy (pipeline);
|
|
|
|
pipeline = copy;
|
2010-12-03 12:46:16 -05:00
|
|
|
}
|
2012-01-07 21:59:04 -05:00
|
|
|
_cogl_pipeline_apply_legacy_state (pipeline);
|
2010-12-03 12:46:16 -05:00
|
|
|
}
|
|
|
|
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 10:59:48 -05:00
|
|
|
_cogl_pipeline_flush_gl_state (pipeline,
|
|
|
|
framebuffer,
|
|
|
|
skip_gl_color,
|
|
|
|
n_tex_coord_attribs);
|
2010-12-03 12:46:16 -05:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_clear_all (&ctx->enable_builtin_attributes_tmp);
|
|
|
|
_cogl_bitmask_clear_all (&ctx->enable_texcoord_attributes_tmp);
|
|
|
|
_cogl_bitmask_clear_all (&ctx->enable_custom_attributes_tmp);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2010-12-03 12:46:16 -05:00
|
|
|
/* Bind the attribute pointers. We need to do this after the
|
2011-11-24 13:09:53 -05:00
|
|
|
* pipeline is flushed because when using GLSL that is the only
|
|
|
|
* point when we can determine the attribute locations */
|
2010-12-03 12:46:16 -05:00
|
|
|
|
2011-03-02 20:02:12 -05:00
|
|
|
for (i = 0; i < n_attributes; i++)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-01-20 14:31:53 -05:00
|
|
|
CoglAttribute *attribute = attributes[i];
|
2011-03-02 10:01:41 -05:00
|
|
|
CoglAttributeBuffer *attribute_buffer;
|
2010-10-12 07:53:10 -04:00
|
|
|
CoglBuffer *buffer;
|
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 16:56:40 -04:00
|
|
|
uint8_t *base;
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-03-02 10:01:41 -05:00
|
|
|
attribute_buffer = cogl_attribute_get_buffer (attribute);
|
|
|
|
buffer = COGL_BUFFER (attribute_buffer);
|
|
|
|
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
switch (attribute->name_state->name_id)
|
2010-10-12 07:53:10 -04:00
|
|
|
{
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
2010-12-03 12:46:16 -05:00
|
|
|
#ifdef HAVE_COGL_GLES2
|
2011-07-07 15:44:56 -04:00
|
|
|
if (ctx->driver == COGL_DRIVER_GLES2)
|
2012-01-07 21:59:04 -05:00
|
|
|
setup_generic_attribute (ctx, pipeline, attribute, base);
|
2011-07-07 15:44:56 -04:00
|
|
|
else
|
2010-12-03 12:46:16 -05:00
|
|
|
#endif
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
|
|
|
|
COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY, TRUE);
|
2011-07-07 15:44:56 -04:00
|
|
|
GE (ctx, glColorPointer (attribute->n_components,
|
|
|
|
attribute->type,
|
|
|
|
attribute->stride,
|
|
|
|
base + attribute->offset));
|
|
|
|
}
|
2010-10-12 07:53:10 -04:00
|
|
|
break;
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
2010-12-03 12:46:16 -05:00
|
|
|
#ifdef HAVE_COGL_GLES2
|
2011-07-07 15:44:56 -04:00
|
|
|
if (ctx->driver == COGL_DRIVER_GLES2)
|
2012-01-07 21:59:04 -05:00
|
|
|
setup_generic_attribute (ctx, pipeline, attribute, base);
|
2011-12-07 08:20:44 -05:00
|
|
|
else
|
2010-12-03 12:46:16 -05:00
|
|
|
#endif
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
|
|
|
|
COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY, TRUE);
|
2011-07-07 15:44:56 -04:00
|
|
|
GE (ctx, glNormalPointer (attribute->type,
|
|
|
|
attribute->stride,
|
|
|
|
base + attribute->offset));
|
|
|
|
}
|
2010-10-12 07:53:10 -04:00
|
|
|
break;
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
2010-12-03 12:46:16 -05:00
|
|
|
#ifdef HAVE_COGL_GLES2
|
2011-07-07 15:44:56 -04:00
|
|
|
if (ctx->driver == COGL_DRIVER_GLES2)
|
2012-01-07 21:59:04 -05:00
|
|
|
setup_generic_attribute (ctx, pipeline, attribute, base);
|
2011-07-07 15:44:56 -04:00
|
|
|
else
|
2010-12-03 12:46:16 -05:00
|
|
|
#endif
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_set (&ctx->enable_texcoord_attributes_tmp,
|
|
|
|
attribute->name_state->texture_unit, TRUE);
|
|
|
|
GE (ctx,
|
|
|
|
glClientActiveTexture (GL_TEXTURE0 +
|
|
|
|
attribute->name_state->texture_unit));
|
2011-07-07 15:44:56 -04:00
|
|
|
GE (ctx, glTexCoordPointer (attribute->n_components,
|
|
|
|
attribute->type,
|
|
|
|
attribute->stride,
|
|
|
|
base + attribute->offset));
|
|
|
|
}
|
2010-10-12 07:53:10 -04:00
|
|
|
break;
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
2010-12-03 12:46:16 -05:00
|
|
|
#ifdef HAVE_COGL_GLES2
|
2011-07-07 15:44:56 -04:00
|
|
|
if (ctx->driver == COGL_DRIVER_GLES2)
|
2012-01-07 21:59:04 -05:00
|
|
|
setup_generic_attribute (ctx, pipeline, attribute, base);
|
2011-07-07 15:44:56 -04:00
|
|
|
else
|
2010-12-03 12:46:16 -05:00
|
|
|
#endif
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp,
|
|
|
|
COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY, TRUE);
|
2011-07-07 15:44:56 -04:00
|
|
|
GE (ctx, glVertexPointer (attribute->n_components,
|
|
|
|
attribute->type,
|
|
|
|
attribute->stride,
|
|
|
|
base + attribute->offset));
|
|
|
|
}
|
2010-10-12 07:53:10 -04:00
|
|
|
break;
|
2011-01-20 14:31:53 -05:00
|
|
|
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
2011-12-07 07:19:58 -05:00
|
|
|
#ifdef COGL_PIPELINE_PROGEND_GLSL
|
2011-07-07 15:44:56 -04:00
|
|
|
if (ctx->driver != COGL_DRIVER_GLES1)
|
2012-01-07 21:59:04 -05:00
|
|
|
setup_generic_attribute (ctx, pipeline, attribute, base);
|
2011-12-07 07:19:58 -05:00
|
|
|
#endif
|
2010-10-12 07:53:10 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("Unrecognised attribute type 0x%08x", attribute->type);
|
|
|
|
}
|
|
|
|
|
|
|
|
_cogl_buffer_unbind (buffer);
|
|
|
|
}
|
|
|
|
|
2012-01-07 21:59:04 -05:00
|
|
|
apply_attribute_enable_updates (ctx, pipeline);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2012-01-07 21:59:04 -05:00
|
|
|
if (copy)
|
|
|
|
cogl_object_unref (copy);
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|
|
|
|
|
2010-12-03 12:46:16 -05:00
|
|
|
void
|
2011-01-20 14:31:53 -05:00
|
|
|
_cogl_attribute_disable_cached_arrays (void)
|
2010-12-03 12:46:16 -05:00
|
|
|
{
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
_cogl_bitmask_clear_all (&ctx->enable_builtin_attributes_tmp);
|
|
|
|
_cogl_bitmask_clear_all (&ctx->enable_texcoord_attributes_tmp);
|
|
|
|
_cogl_bitmask_clear_all (&ctx->enable_custom_attributes_tmp);
|
2010-10-12 07:53:10 -04:00
|
|
|
|
2011-11-24 13:09:53 -05:00
|
|
|
/* XXX: we can pass a NULL source pipeline here because we know a
|
|
|
|
* source pipeline only needs to be referenced when enabling
|
|
|
|
* attributes. */
|
|
|
|
apply_attribute_enable_updates (ctx, NULL);
|
2010-10-12 07:53:10 -04:00
|
|
|
}
|