1
0
Fork 0

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.
This commit is contained in:
Neil Roberts 2010-05-12 15:19:09 +01:00
parent 502446ed8d
commit dd9e7853ec

View file

@ -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 static void
_cogl_material_flush_base_gl_state (CoglMaterial *material, _cogl_material_flush_base_gl_state (CoglMaterial *material,
gboolean skip_gl_color) gboolean skip_gl_color)
@ -1697,6 +1710,15 @@ _cogl_material_flush_base_gl_state (CoglMaterial *material,
#endif #endif
#ifndef HAVE_COGL_GLES /* GLES 1 only has glBlendFunc */ #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 && if (have_blend_func_separate &&
(material->blend_src_factor_rgb != material->blend_src_factor_alpha || (material->blend_src_factor_rgb != material->blend_src_factor_alpha ||
(material->blend_src_factor_rgb != (material->blend_src_factor_rgb !=
@ -1713,10 +1735,6 @@ _cogl_material_flush_base_gl_state (CoglMaterial *material,
material->blend_dst_factor_rgb, material->blend_dst_factor_rgb,
material->blend_src_factor_alpha, material->blend_src_factor_alpha,
material->blend_dst_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 else
#endif #endif