From dd9e7853ece631be48ac85e3a984bfb93a127b43 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 12 May 2010 15:19:09 +0100 Subject: [PATCH] cogl-material: Set blend constant even if alpha and rgb factors are the same Previously it would only set the blend constant if glBlendFuncSeparate was used but it is perfectly acceptable to use the blend constant when the same factor is used for each. It now sets the blend constant whenever one of the factors would use the constant. --- clutter/cogl/cogl/cogl-material.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index d13988cb5..8f5e414b5 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -1636,6 +1636,19 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, } } +#ifndef HAVE_COGL_GLES + +static gboolean +blend_factor_uses_constant (GLenum blend_factor) +{ + return (blend_factor == GL_CONSTANT_COLOR || + blend_factor == GL_ONE_MINUS_CONSTANT_COLOR || + blend_factor == GL_CONSTANT_ALPHA || + blend_factor == GL_ONE_MINUS_CONSTANT_ALPHA); +} + +#endif + static void _cogl_material_flush_base_gl_state (CoglMaterial *material, gboolean skip_gl_color) @@ -1697,6 +1710,15 @@ _cogl_material_flush_base_gl_state (CoglMaterial *material, #endif #ifndef HAVE_COGL_GLES /* GLES 1 only has glBlendFunc */ + if (blend_factor_uses_constant (material->blend_src_factor_rgb) || + blend_factor_uses_constant (material->blend_src_factor_alpha) || + blend_factor_uses_constant (material->blend_dst_factor_rgb) || + blend_factor_uses_constant (material->blend_dst_factor_alpha)) + GE (glBlendColor (material->blend_constant[0], + material->blend_constant[1], + material->blend_constant[2], + material->blend_constant[3])); + if (have_blend_func_separate && (material->blend_src_factor_rgb != material->blend_src_factor_alpha || (material->blend_src_factor_rgb != @@ -1713,10 +1735,6 @@ _cogl_material_flush_base_gl_state (CoglMaterial *material, material->blend_dst_factor_rgb, material->blend_src_factor_alpha, material->blend_dst_factor_alpha)); - GE (glBlendColor (material->blend_constant[0], - material->blend_constant[1], - material->blend_constant[2], - material->blend_constant[3])); } else #endif