Hi,
I had done a second test, changing the interactive test "test-multistage.c".
If you try the modified test, you can see the texture moving along the
window-stage; but if you add more than 1 added stage
the movement loses fluidity.

You know if there is a solution, or it's a problem with my hardware or a
clutter limit ?

Thank's in advance

Modified code:

#include <gmodule.h>
#include <clutter/clutter.h>

static gint n_stages = 1;

static gboolean
tex_button_cb (ClutterActor    *actor,
               ClutterEvent    *event,
               gpointer         data)
{
  clutter_actor_hide (actor);

  return TRUE;
}

static gboolean
on_button_press (ClutterActor *actor,
                 ClutterEvent *event,
                 gpointer      data)
{
  ClutterActor *new_stage;
  ClutterActor *label, *tex;
  gint width, height;
  gchar *stage_label, *win_title;
  ClutterColor color = { 0xdd, 0x33, 0xdd, 0xff };
  ClutterColor white = { 0x99, 0x99, 0x99, 0xff };
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *m_behave;
  ClutterPath      *m_path;

  new_stage = clutter_stage_new ();
  if (!new_stage)
    return FALSE;

  /* FIXME: below should really be automatic */
  /* clutter_stage_ensure_cogl_context (CLUTTER_STAGE(new_stage)); */

  clutter_stage_set_color (CLUTTER_STAGE (new_stage), &color);
  clutter_actor_set_size (new_stage, 320, 240);

  tex = clutter_texture_new_from_file (TESTS_DATADIR
                                       G_DIR_SEPARATOR_S
                                       "redhand.png",
                                       NULL);

  if (!tex)
    g_error ("pixbuf load failed");

  clutter_actor_set_reactive (tex, TRUE);
  g_signal_connect (tex, "button-press-event",
                    G_CALLBACK (tex_button_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (new_stage), tex);

  stage_label = g_strdup_printf ("<b>Stage: %d</b>", ++n_stages);
  label = clutter_text_new_with_text ("Mono 12", stage_label);

  clutter_text_set_color (CLUTTER_TEXT (label), &white);
  clutter_text_set_use_markup (CLUTTER_TEXT (label), TRUE);
  width = (clutter_actor_get_width (new_stage)
           - clutter_actor_get_width (label)) / 2;
  height = (clutter_actor_get_height (new_stage)
            - clutter_actor_get_height (label)) / 2;
  clutter_actor_set_position (label, width, height);
  clutter_container_add_actor (CLUTTER_CONTAINER (new_stage), label);
  clutter_actor_show (label);
  g_free (stage_label);

  /*
  g_signal_connect (new_stage, "button-press-event",
                    G_CALLBACK (clutter_actor_destroy),
                    NULL);
  */

  win_title =   g_strdup_printf ("Stage:%p", new_stage);
  clutter_stage_set_title (CLUTTER_STAGE(new_stage), win_title);

  timeline = clutter_timeline_new ((long)(320.0 * 16.6666 / 4.0));
  clutter_timeline_set_loop (timeline, TRUE);

  alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);

  m_path = clutter_path_new ();
  clutter_path_add_move_to (m_path, 0, 0);
  clutter_path_add_line_to (m_path, 320, 0);

  m_behave = clutter_behaviour_path_new (alpha, m_path);

  clutter_behaviour_apply (m_behave, tex);
  clutter_timeline_start (timeline);

  clutter_actor_show_all (new_stage);

  return TRUE;
}

G_MODULE_EXPORT int
test_multistage_main (int argc, char *argv[])
{
  ClutterActor *stage_default;
  ClutterActor *label;
  gint width, height;
  gchar *win_title;

  clutter_init (&argc, &argv);

  stage_default = clutter_stage_get_default ();
  g_signal_connect (stage_default, "button-press-event",
                    G_CALLBACK (on_button_press),
                    NULL);

  label = clutter_text_new_with_text ("Mono 16", "Default stage");
  width = (clutter_actor_get_width (stage_default)
           - clutter_actor_get_width (label))
             / 2;
  height = (clutter_actor_get_height (stage_default)
            - clutter_actor_get_height (label))
            / 2;
  clutter_actor_set_position (label, width, height);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage_default), label);
  clutter_actor_show (label);

  win_title =   g_strdup_printf ("Stage:%p", stage_default);
  clutter_stage_set_title (CLUTTER_STAGE(stage_default), win_title);

  clutter_actor_show (stage_default);

  clutter_main ();

  return 0;
}

2010/11/10 Angelo Butti <buttiang...@gmail.com>

> Hi all,
> I have this problem.
>
> I must move different textures on different stage; to do this I had created
> two stages (the defalt + the new one),
> 2 textures, one for each stage and a timeline connected to "new-frame".
> Than, I had used the clutter_actor_set_position for each texture inside the
> callback function "new-frame" to move the texture.
>
> All is ok if I use only 1 stage, but with 2 stages (= 2 windows on the
> monitor), the framerate decrise.
>
> Below the example without texture but with a rectangle :
> (I use Fedora 13 with nVidia GeForce 7300 go)
>
> (comment/uncomment -> " clutter_actor_set_position (rect1, x_pos, 0); " to
> see the framerate difference !! ):
>
> #include <glib.h>
>
> #include <clutter/clutter.h>
> #include <stdlib.h>
>
> ClutterActor *rect = NULL;
> ClutterActor *rect1 = NULL;
>
> GError *error;
>
> char dir  = 0;
> int x_pos = 640;
>
> void
> on_timeline_new_frame (ClutterTimeline *timeline,
>   gint frame_num, gpointer data)
> {
>     if (!dir)
>         x_pos = x_pos - 4;
>     else
>         x_pos = x_pos + 4;
>
>     if (x_pos == 0)
>         dir = !dir;
>     else if (x_pos == 640)
>         dir = !dir;
>
>     clutter_actor_set_position (rect, x_pos, 0);
>     clutter_actor_set_position (rect1, x_pos, 0);
> }
>
> int main(int argc, char *argv[])
> {
>   ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
>   ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 };
>
>   clutter_init (&argc, &argv);
>
>   /* Get the stage and set its size and color: */
>   ClutterActor *stage = clutter_stage_get_default ();
>   clutter_actor_set_size (stage, 640, 400);
>   clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
>
>   ClutterActor *stage1 = clutter_stage_new();
>   clutter_actor_set_size (stage1, 640, 400);
>   clutter_stage_set_color (CLUTTER_STAGE (stage1), &stage_color);
>
>   /* Add a rectangle to the stage: */
>   rect = clutter_rectangle_new_with_color (&rect_color);
>   clutter_actor_set_size (rect, 640, 400);
>   clutter_actor_set_position (rect, 640, 0);
>   clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
>   clutter_actor_show (rect);
>
>   /* Add a rectangle to the stage: */
>   rect1 = clutter_rectangle_new_with_color (&rect_color);
>   clutter_actor_set_size (rect1, 640, 400);
>   clutter_actor_set_position (rect1, 640, 0);
>   clutter_container_add_actor (CLUTTER_CONTAINER (stage1), rect1);
>   clutter_actor_show (rect1);
>
>   /* Show the stage: */
>   clutter_actor_show (stage);
>   clutter_actor_show (stage1);
>
>   ClutterTimeline *timeline = clutter_timeline_new(1000 /* milliseconds
> */);
>   g_signal_connect (timeline, "new-frame", G_CALLBACK
> (on_timeline_new_frame), NULL);
>   clutter_timeline_set_loop(timeline, TRUE);
>   clutter_timeline_start(timeline);
>
>   /* Start the main loop, so we can respond to events: */
>   clutter_main ();
>
>   g_object_unref (timeline);
>
>   return EXIT_SUCCESS;
> }
>
>
> Where is the problem ?
> Angelo
>
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list@clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to