summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2009-02-19 09:20:20 +0000
committerRobert Bragg <robert@linux.intel.com>2009-02-23 10:49:35 +0000
commit114385b2cf0f6aa09725bece92ce8eae6e5823e2 (patch)
tree8986d3c063e2728aa68a659d9e9dce64d310eed7 /common
parent25fc1b85ab2ea9aaa71f1bb03623ca4a484b7be8 (diff)
downloadcogl-114385b2cf0f6aa09725bece92ce8eae6e5823e2.tar.gz
[cogl-material] Always glBindTexture when flushing material state
Bug #1457 - Creating a new texture messes up the cogl material state cache; reported by Neil Roberts We still don't have caching of bound texture state so we always have to re-bind the texture when flushing the GL state of any material layers.
Diffstat (limited to 'common')
-rw-r--r--common/cogl-material.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/common/cogl-material.c b/common/cogl-material.c
index b7cf11c5..7ee64196 100644
--- a/common/cogl-material.c
+++ b/common/cogl-material.c
@@ -903,25 +903,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
(fallback_mask & (1<<i)) ? TRUE : FALSE;
new_gl_layer_info.disabled =
(disable_mask & (1<<i)) ? TRUE : FALSE;
- if (i < ctx->current_layers->len)
- {
- gl_layer_info =
- &g_array_index (ctx->current_layers, CoglLayerInfo, i);
-
-#ifndef DISABLE_MATERIAL_CACHE
- if (gl_layer_info->handle == layer_handle &&
- !(layer->flags & COGL_MATERIAL_LAYER_FLAG_DIRTY) &&
- !(gl_layer_info->layer0_overridden ||
- new_gl_layer_info.layer0_overridden) &&
- (gl_layer_info->fallback
- == new_gl_layer_info.fallback) &&
- (gl_layer_info->disabled
- == new_gl_layer_info.disabled))
- {
- continue;
- }
-#endif
- }
tex_handle = layer->texture;
cogl_texture_get_gl_texture (tex_handle, &gl_texture, &gl_target);
@@ -972,6 +953,29 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
GE (glBindTexture (gl_target, gl_texture));
#endif
+ /* XXX: Once we add caching for glBindTexture state, these
+ * checks should be moved back up to the top of the loop!
+ */
+ if (i < ctx->current_layers->len)
+ {
+ gl_layer_info =
+ &g_array_index (ctx->current_layers, CoglLayerInfo, i);
+
+#ifndef DISABLE_MATERIAL_CACHE
+ if (gl_layer_info->handle == layer_handle &&
+ !(layer->flags & COGL_MATERIAL_LAYER_FLAG_DIRTY) &&
+ !(gl_layer_info->layer0_overridden ||
+ new_gl_layer_info.layer0_overridden) &&
+ (gl_layer_info->fallback
+ == new_gl_layer_info.fallback) &&
+ (gl_layer_info->disabled
+ == new_gl_layer_info.disabled))
+ {
+ continue;
+ }
+#endif
+ }
+
/* Disable the previous target if it was different */
#ifndef DISABLE_MATERIAL_CACHE
if (gl_layer_info &&