2011-07-08 11:08:19 +00:00
|
|
|
#undef CLUTTER_DISABLE_DEPRECATED
|
2008-10-29 14:52:48 +00:00
|
|
|
|
2008-02-01 15:29:00 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <glib.h>
|
2008-11-07 19:32:28 +00:00
|
|
|
#include <gmodule.h>
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
#define STAGE_WIDTH 800
|
|
|
|
#define STAGE_HEIGHT 600
|
|
|
|
|
|
|
|
ClutterActor *
|
|
|
|
make_source (void)
|
2008-02-01 15:29:00 +00:00
|
|
|
{
|
2009-10-07 09:40:15 +00:00
|
|
|
ClutterActor *source, *actor;
|
2009-11-05 17:30:33 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
gchar *file;
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
ClutterColor yellow = {0xff, 0xff, 0x00, 0xff};
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2009-11-05 17:30:33 +00:00
|
|
|
source = clutter_group_new ();
|
|
|
|
|
|
|
|
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
|
|
|
|
actor = clutter_texture_new_from_file (file, &error);
|
2008-04-25 13:37:36 +00:00
|
|
|
if (!actor)
|
2008-02-01 15:29:00 +00:00
|
|
|
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
|
|
|
|
|
2009-11-05 17:30:33 +00:00
|
|
|
g_free (file);
|
|
|
|
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (source), actor);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-12-11 13:48:01 +00:00
|
|
|
actor = clutter_text_new_with_text ("Sans Bold 50px", "Clutter");
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-12-11 13:48:01 +00:00
|
|
|
clutter_text_set_color (CLUTTER_TEXT (actor), &yellow);
|
2008-02-03 01:53:10 +00:00
|
|
|
clutter_actor_set_y (actor, clutter_actor_get_height(source) + 5);
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (source), actor);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
return source;
|
|
|
|
}
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
G_MODULE_EXPORT int
|
|
|
|
test_fbo_main (int argc, char *argv[])
|
2008-02-03 01:53:10 +00:00
|
|
|
{
|
|
|
|
ClutterColor blue = {0x33, 0x44, 0x55, 0xff};
|
|
|
|
|
|
|
|
ClutterActor *fbo;
|
2009-10-07 09:40:15 +00:00
|
|
|
ClutterActor *onscreen_source;
|
2008-02-03 01:53:10 +00:00
|
|
|
ClutterActor *stage;
|
2009-10-07 09:40:15 +00:00
|
|
|
ClutterAnimation *animation;
|
|
|
|
int x_pos = 200;
|
|
|
|
int y_pos = 100;
|
2008-02-03 01:53:10 +00:00
|
|
|
|
2011-02-22 00:19:35 +00:00
|
|
|
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
|
|
|
return 1;
|
2008-02-03 01:53:10 +00:00
|
|
|
|
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE)
|
|
|
|
g_error("This test requires CLUTTER_FEATURE_OFFSCREEN");
|
|
|
|
|
|
|
|
stage = clutter_stage_get_default ();
|
2009-10-07 09:40:15 +00:00
|
|
|
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
2008-02-03 01:53:10 +00:00
|
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &blue);
|
|
|
|
|
|
|
|
/* Create the first source */
|
|
|
|
onscreen_source = make_source();
|
|
|
|
clutter_actor_show_all (onscreen_source);
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), onscreen_source);
|
2008-02-03 01:53:10 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
y_pos = (STAGE_HEIGHT/2.0) -
|
|
|
|
(clutter_actor_get_height (onscreen_source)/2.0);
|
|
|
|
clutter_actor_set_position (onscreen_source, x_pos, y_pos);
|
|
|
|
x_pos += clutter_actor_get_width (onscreen_source);
|
|
|
|
|
|
|
|
animation = clutter_actor_animate (onscreen_source,
|
|
|
|
CLUTTER_LINEAR,
|
|
|
|
5000, /* 1 second duration */
|
|
|
|
"rotation-angle-y", 360.0f,
|
|
|
|
NULL);
|
|
|
|
clutter_animation_set_loop (animation, TRUE);
|
2008-02-03 01:53:10 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
/* Second hand = actor from onscreen_source */
|
2008-02-03 01:53:10 +00:00
|
|
|
if ((fbo = clutter_texture_new_from_actor (onscreen_source)) == NULL)
|
|
|
|
g_error("onscreen fbo creation failed");
|
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
clutter_actor_set_position (fbo, x_pos, y_pos);
|
|
|
|
x_pos += clutter_actor_get_width (fbo);
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), fbo);
|
2008-02-03 01:53:10 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
/* Third hand = actor from Second hand */
|
|
|
|
if ((fbo = clutter_texture_new_from_actor (fbo)) == NULL)
|
|
|
|
g_error("fbo from fbo creation failed");
|
2008-02-03 01:53:10 +00:00
|
|
|
|
2009-10-07 09:40:15 +00:00
|
|
|
clutter_actor_set_position (fbo, x_pos, y_pos);
|
|
|
|
x_pos += clutter_actor_get_width (fbo);
|
2011-06-16 16:07:32 +00:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), fbo);
|
2008-02-03 01:53:10 +00:00
|
|
|
|
2008-02-01 15:29:00 +00:00
|
|
|
clutter_actor_show_all (stage);
|
|
|
|
clutter_main ();
|
2008-02-11 16:29:31 +00:00
|
|
|
|
|
|
|
return 0;
|
2008-02-01 15:29:00 +00:00
|
|
|
}
|