effects: Check before using the cogl_shader_* API
authorEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 11 Aug 2010 16:25:17 +0000 (17:25 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 11 Aug 2010 16:25:17 +0000 (17:25 +0100)
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
clutter/clutter-desaturate-effect.c

index c25370c..34e9a80 100644 (file)
@@ -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);
 
index a06890b..59be9ea 100644 (file)
@@ -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)