From a8b563b622e5061dd6d0d1164ca5fa79b24ab008 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sun, 29 Nov 2009 20:06:36 +0000 Subject: [PATCH] cogl: Enable blending if a lighting colour is semi-transparent We currently enable blending if the material colour has transparency. This patch makes it also enable blending if any of the lighting colours have transparency. Arguably this isn't neccessary because we don't expose any API to enable lighting so there is no bug. However it is currently possible to enable lighting with a direct call to glEnable and this otherwise works so it is a shame not to have it. http://bugzilla.openedhand.com/show_bug.cgi?id=1907 --- cogl/cogl-material.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c index b7ed041c2..1a641a776 100644 --- a/cogl/cogl-material.c +++ b/cogl/cogl-material.c @@ -175,7 +175,11 @@ _cogl_material_needs_blending_enabled (CoglMaterial *material, #endif if ((override_color && override_color[3] != 0xff) || - material->unlit[3] != 0xff) + material->unlit[3] != 0xff || + material->ambient[3] != 1.0f || + material->diffuse[3] != 1.0f || + material->specular[3] != 1.0f || + material->emission[3] != 1.0f) return TRUE; for (tmp = material->layers; tmp != NULL; tmp = tmp->next) @@ -349,6 +353,8 @@ cogl_material_set_ambient (CoglHandle handle, ambient[3] = cogl_color_get_alpha_float (ambient_color); material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_GL_MATERIAL; + + handle_automatic_blend_enable (material); } void @@ -389,6 +395,8 @@ cogl_material_set_diffuse (CoglHandle handle, diffuse[3] = cogl_color_get_alpha_float (diffuse_color); material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_GL_MATERIAL; + + handle_automatic_blend_enable (material); } void @@ -437,6 +445,8 @@ cogl_material_set_specular (CoglHandle handle, specular[3] = cogl_color_get_alpha_float (specular_color); material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_GL_MATERIAL; + + handle_automatic_blend_enable (material); } float @@ -511,6 +521,8 @@ cogl_material_set_emission (CoglHandle handle, emission[3] = cogl_color_get_alpha_float (emission_color); material->flags &= ~COGL_MATERIAL_FLAG_DEFAULT_GL_MATERIAL; + + handle_automatic_blend_enable (material); } void