From 34b50934be581cde0ef2eba75f45aa36b1add14d Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 5 Dec 2009 14:20:00 +0000 Subject: [PATCH] cogl-material: Ensure mipmaps before doing anything else on a texture When the texture is in the atlas, ensuring the mipmaps can effectively make it become a completely different texture so we should do this before getting the GL handle. --- clutter/cogl/cogl/cogl-material.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index 1a641a776..cbccf3724 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -1400,7 +1400,17 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, tex_handle = layer->texture; if (tex_handle != COGL_INVALID_HANDLE) - cogl_texture_get_gl_texture (tex_handle, &gl_texture, &gl_target); + { + if (is_mipmap_filter (layer->min_filter) + || is_mipmap_filter (layer->mag_filter)) + _cogl_texture_ensure_mipmaps (tex_handle); + + _cogl_texture_set_filters (tex_handle, + layer->min_filter, + layer->mag_filter); + + cogl_texture_get_gl_texture (tex_handle, &gl_texture, &gl_target); + } else { new_gl_layer_info.fallback = TRUE; @@ -1431,13 +1441,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, GE (glActiveTexture (GL_TEXTURE0 + i)); unit = _cogl_get_texture_unit (i); - _cogl_texture_set_filters (layer->texture, - layer->min_filter, - layer->mag_filter); - if (is_mipmap_filter (layer->min_filter) - || is_mipmap_filter (layer->mag_filter)) - _cogl_texture_ensure_mipmaps (layer->texture); - /* FIXME: We could be more clever here and only bind the texture if it is different from gl_layer_info->gl_texture to avoid redundant GL calls. However a few other places in Cogl and