[cogl] cogl-attribute: Fix binding an attribute to cogl_tex_coord_in
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] cogl-attribute: Fix binding an attribute to cogl_tex_coord_in
- Date: Wed, 22 Feb 2012 17:30:01 +0000 (UTC)
commit d3e6f2bc833e43a7795cfead26face2d8e61f5fd
Author: Neil Roberts <neil linux intel com>
Date: Wed Feb 22 15:51:57 2012 +0000
cogl-attribute: Fix binding an attribute to cogl_tex_coord_in
If an application tries to bind an attribute to cogl_tex_coord_in then
on GLES2 it would try to directly use that as the name of the GL
attribute. However in the generated shader that is actually #defined
to cogl_tex_coord0_in so we need to remap the name. This adds a
parameter to validate_cogl_attribute_name so that it can optionally
return a real_attribute_name. If it doesn't set this then the calling
function will default to the Cogl attribute name.
This fixes test-texture-3d with the GLES2 driver.
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/cogl-attribute.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c
index ddc3596..e9f6cef 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -61,6 +61,7 @@ COGL_OBJECT_DEFINE (Attribute, attribute);
static gboolean
validate_cogl_attribute_name (const char *name,
+ char **real_attribute_name,
CoglAttributeNameID *name_id,
gboolean *normalized,
int *texture_unit)
@@ -78,7 +79,10 @@ validate_cogl_attribute_name (const char *name,
*normalized = TRUE;
}
else if (strcmp (name, "tex_coord_in") == 0)
- *name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
+ {
+ *real_attribute_name = "cogl_tex_coord0_in";
+ *name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
+ }
else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0)
{
char *endptr;
@@ -86,7 +90,7 @@ validate_cogl_attribute_name (const char *name,
if (strcmp (endptr, "_in") != 0)
{
g_warning ("Texture coordinate attributes should either be named "
- "\"cogl_tex_coord\" or named with a texture unit index "
+ "\"cogl_tex_coord_in\" or named with a texture unit index "
"like \"cogl_tex_coord2_in\"\n");
return FALSE;
}
@@ -112,16 +116,18 @@ _cogl_attribute_register_attribute_name (CoglContext *context,
{
CoglAttributeNameState *name_state = g_new (CoglAttributeNameState, 1);
int name_index = context->n_attribute_names++;
+ char *name_copy = g_strdup (name);
- name_state->name = g_strdup (name);
+ name_state->name = NULL;
name_state->name_index = name_index;
if (strncmp (name, "cogl_", 5) == 0)
{
if (!validate_cogl_attribute_name (name,
+ &name_state->name,
&name_state->name_id,
&name_state->normalized_default,
&name_state->texture_unit))
- goto error;
+ goto error;
}
else
{
@@ -130,8 +136,11 @@ _cogl_attribute_register_attribute_name (CoglContext *context,
name_state->texture_unit = 0;
}
+ if (name_state->name == NULL)
+ name_state->name = name_copy;
+
g_hash_table_insert (context->attribute_name_states_hash,
- name_state->name, name_state);
+ name_copy, name_state);
if (G_UNLIKELY (context->attribute_name_index_map == NULL))
context->attribute_name_index_map =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]