From d10ebe9fcaf28b85d707ea41f5856632f9c8a934 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 11 Aug 2010 17:25:17 +0100 Subject: [PATCH] effects: Check before using the cogl_shader_* API Since BlurEffect and DesaturateEffect are using the shader API implicitly and not using ClutterShaderEffect, we need to check if the underlying GL implementation supports the GLSL shading language and warn if not. --- clutter/clutter-blur-effect.c | 12 ++++++++++++ clutter/clutter-desaturate-effect.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/clutter/clutter-blur-effect.c b/clutter/clutter-blur-effect.c index c25370c..34e9a80 100644 --- a/clutter/clutter-blur-effect.c +++ b/clutter/clutter-blur-effect.c @@ -137,6 +137,18 @@ clutter_blur_effect_pre_paint (ClutterEffect *effect) if (self->actor == NULL) return FALSE; + if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) + { + /* if we don't have support for GLSL shaders then we + * forcibly disable the ActorMeta + */ + g_warning ("Unable to use the ShaderEffect: the graphics hardware " + "or the current GL driver does not implement support " + "for the GLSL shading language."); + clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE); + return FALSE; + } + clutter_actor_get_allocation_box (self->actor, &allocation); clutter_actor_box_get_size (&allocation, &width, &height); diff --git a/clutter/clutter-desaturate-effect.c b/clutter/clutter-desaturate-effect.c index a06890b..59be9ea 100644 --- a/clutter/clutter-desaturate-effect.c +++ b/clutter/clutter-desaturate-effect.c @@ -132,6 +132,18 @@ clutter_desaturate_effect_pre_paint (ClutterEffect *effect) if (self->actor == NULL) return FALSE; + if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) + { + /* if we don't have support for GLSL shaders then we + * forcibly disable the ActorMeta + */ + g_warning ("Unable to use the ShaderEffect: the graphics hardware " + "or the current GL driver does not implement support " + "for the GLSL shading language."); + clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE); + return FALSE; + } + factor = (float) self->factor; if (self->shader == COGL_INVALID_HANDLE) -- 2.7.4