Update the svn:ignore property
authorEmmanuele Bassi <ebassi@openedhand.com>
Thu, 6 Dec 2007 10:57:29 +0000 (10:57 +0000)
committerEmmanuele Bassi <ebassi@openedhand.com>
Thu, 6 Dec 2007 10:57:29 +0000 (10:57 +0000)
tests/test-shader.c

index d4e3ecc..40d8e0b 100644 (file)
@@ -127,7 +127,7 @@ static ShaderSource shaders[]=
     {NULL, NULL}
 };
 
-static gint shader_no=0;
+static gint shader_no = 2;
 
 static gboolean
 button_release_cb (ClutterActor    *actor,
@@ -135,27 +135,48 @@ button_release_cb (ClutterActor    *actor,
                    gpointer         data)
 {
   gint new_no;
+
   if (event->button.button == 1)
     {
-      new_no = shader_no-1;
+      new_no = shader_no - 1;
     }
   else
     {
-      new_no = shader_no+1;
+      new_no = shader_no + 1;
     }
 
   if (new_no >= 0 && shaders[new_no].name)
     {
       ClutterShader *shader;
+      GError *error;
       shader_no = new_no;
       
-      g_print ("setting shaders[%i] named '%s'\n", shader_no, shaders[shader_no].name);
-      shader = clutter_shader_new_from_strings (NULL, shaders[shader_no].source);
-      clutter_actor_apply_shader (actor, shader);
+      g_print ("setting shaders[%i] named '%s'\n",
+               shader_no,
+               shaders[shader_no].name);
+
+      shader = clutter_shader_new ();
       
-      clutter_actor_set_shader_param (actor, "radius", 3.0);
-      clutter_redraw();
+      error = NULL;
+      clutter_shader_load_from_data (shader, CLUTTER_FRAGMENT_SHADER,
+                                     shaders[shader_no].source, -1,
+                                     &error);
+      if (error)
+        {
+          g_print ("unable to set shaders[%i] named '%s': %s",
+                   error->message);
+          g_error_free (error);
+          g_object_unref (shader);
+        }
+      else
+        {
+          clutter_actor_apply_shader (actor, shader);
+          clutter_actor_set_shader_param (actor, "radius", 3.0);
+
+          clutter_actor_queue_redraw (actor);
+        }
     }
+
   return FALSE;
 }
 
@@ -173,19 +194,35 @@ main (gint   argc,
   GError           *error;
   ClutterShader    *shader;
 
-  error = NULL;
-
   clutter_init (&argc, &argv);
-  g_print ("applying shaders[%i] named '%s'\n", shader_no, shaders[shader_no].name);
-  shader = clutter_shader_new_from_strings (NULL, shaders[shader_no].source);
 
   stage = clutter_stage_get_default ();
   clutter_actor_set_size (stage, 512, 384);
 
-  pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
+  g_print ("applying shaders[%i] named '%s'\n",
+           shader_no,
+           shaders[shader_no].name);
+
+  shader = clutter_shader_new ();
 
+  error = NULL;
+  clutter_shader_load_from_data (shader, CLUTTER_FRAGMENT_SHADER,
+                                 shaders[shader_no].source, -1,
+                                 &error);
+  if (error)
+    {
+      g_print ("unable to load shaders[%d] named '%s': %s\n",
+               shader_no,
+               shaders[shader_no].name,
+               error->message);
+      g_error_free (error);
+
+      return EXIT_FAILURE;
+    }
+
+  pixbuf = gdk_pixbuf_new_from_file ("redhand.png", &error);
   if (!pixbuf)
-    g_error("pixbuf load failed");
+    g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
 
   clutter_stage_set_title (CLUTTER_STAGE (stage), "Shader Test");
   clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
@@ -200,7 +237,7 @@ main (gint   argc,
   actor = clutter_group_new ();
     {
       ClutterActor *child1, *child2, *child3, *child4;
-      ClutterColor  color={0xff, 0x22, 0x66, 0x99};
+      ClutterColor  color = { 0xff, 0x22, 0x66, 0x99 };
 
       child1 = clutter_texture_new_from_pixbuf (pixbuf);
       child2 = clutter_texture_new_from_pixbuf (pixbuf);
@@ -218,9 +255,11 @@ main (gint   argc,
       clutter_group_add (CLUTTER_GROUP (actor), child2);
       clutter_group_add (CLUTTER_GROUP (actor), child3);
       clutter_group_add (CLUTTER_GROUP (actor), child4);
+
       clutter_actor_show_all (actor);
     }
 #endif
+
   clutter_actor_set_position (actor, 100, 100);
 
   clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
@@ -242,5 +281,5 @@ main (gint   argc,
 
   clutter_main ();
 
-  return 0;
+  return EXIT_SUCCESS;
 }