Hi All,
I'm seeing a flicker on window resize with an Animation,
and would like to ask if anyone else has this issue?
It might be my graphics card driver, but I have doubts it is.
I'm using version: 1.6.14-0ubuntu3 (libclutter-1.0-0) from the Ubuntu
Software Repository.
Please see attached demo to confirm.
Try this:
1) Size only by Height. Lots of Flicker! :(
2) Size only by Width. Flicker happens allot less!
3) Left click on the Blue animated box to stop the animation
4) Do (1) and (2). No flicker! :)
Workarounds, Hints, Tips, are All welcome! ;)
Thanks again,
Izzy.
#include <clutter/clutter.h>
ClutterActor *stage;
ClutterActor *rect1, *rect2;
ClutterActor *text1, *text2;
ClutterActor *rect_anim;
ClutterActor *rect_anim_text;
ClutterTimeline *timeline;
ClutterAnimator *animator;
gchar txt[1024] = {0};
gfloat window_width;
gfloat window_height;
gboolean
on_rect_anim_button_press( ClutterActor *actor, ClutterEvent *event, gpointer user_data )
{
gboolean bReturn = TRUE;
if( clutter_timeline_is_playing( timeline ) )
clutter_timeline_stop( timeline );
else
clutter_timeline_start( timeline );
return bReturn;
}
void
Rectangle_Animation_Signals_Init()
{
g_signal_connect( rect_anim, "button-press-event", G_CALLBACK( on_rect_anim_button_press ), NULL );
}
void
Rectangle_Animation_Init()
{
rect_anim = clutter_rectangle_new_with_color( CLUTTER_COLOR_SkyBlue );
clutter_container_add( CLUTTER_CONTAINER( stage ), rect_anim, NULL );
clutter_actor_set_position( rect_anim, 10, 200 );
clutter_actor_set_size( rect_anim, 380, 380 );
clutter_actor_set_reactive( rect_anim, TRUE );
clutter_actor_show( rect_anim );
rect_anim_text = clutter_text_new_full( "Arial", "Click Me to Start/Stop Animation", CLUTTER_COLOR_White );
clutter_container_add( CLUTTER_CONTAINER( stage ), rect_anim_text, NULL );
clutter_actor_set_position( rect_anim_text, 10, 220 );
//clutter_actor_set_size( rect_anim_text, 20, 1000 );
clutter_actor_show( rect_anim_text );
timeline = clutter_timeline_new( 2000 );
//g_signal_connect( timeline, "completed", G_CALLBACK( on_Timeline_Completed ), NULL );
clutter_timeline_set_loop( timeline, TRUE );
clutter_timeline_set_auto_reverse( timeline, TRUE );
animator = clutter_animator_new();
clutter_animator_set_timeline( animator, timeline );
clutter_animator_set( animator,
rect_anim, "x", CLUTTER_LINEAR, 0.0, 10.0,
rect_anim, "x", CLUTTER_LINEAR, 1.0, 400.0,
rect_anim_text, "x", CLUTTER_LINEAR, 0.0, 20.0,
rect_anim_text, "x", CLUTTER_LINEAR, 1.0, 410.0,
NULL );
clutter_animator_start( animator );
}
void
Rectangle_Animation_Destroy()
{
g_object_unref( animator );
}
void
Rectangles_Init()
{
rect1 = clutter_rectangle_new_with_color( CLUTTER_COLOR_LightGray );
clutter_container_add( CLUTTER_CONTAINER( stage ), rect1, NULL );
clutter_actor_set_position( rect1, 0, 0 );
//clutter_actor_set_size( rect1, 10, 20 );
clutter_actor_show( rect1 );
text1 = clutter_text_new_full( "Arial", "This Text Should be Stationary at all times.", CLUTTER_COLOR_Black );
clutter_container_add( CLUTTER_CONTAINER( stage ), text1, NULL );
clutter_actor_set_position( text1, 5, 3 );
//clutter_actor_set_size( text1, 10, 10 );
clutter_actor_show( text1 );
rect2 = clutter_rectangle_new_with_color( CLUTTER_COLOR_DarkGray );
clutter_container_add( CLUTTER_CONTAINER( stage ), rect2, NULL );
clutter_actor_set_position( rect2, 0, 20 );
//clutter_actor_set_size( rect2, 10, 10 );
clutter_actor_show( rect2 );
text2 = clutter_text_new_full( "Arial", "This Text Should be Stationary at all times.", CLUTTER_COLOR_White );
clutter_container_add( CLUTTER_CONTAINER( stage ), text2, NULL );
clutter_actor_set_position( text2, 5, 23 );
//clutter_actor_set_size( text2, 10, 10 );
clutter_actor_show( text2 );
}
void
Rectangles_Resize()
{
clutter_actor_set_size( rect1, window_width, 20 );
clutter_actor_set_size( rect2, window_width, window_height - 20 );
}
void
on_Stage_Resized( ClutterActor *actor, ClutterActorBox *box, ClutterAllocationFlags flags, gpointer user_data)
{
window_width = box->x2 - box->x1;
window_height = box->y2 - box->y1;
Rectangles_Resize();
//This1_Resize();
//That1_Resize();
//This2_Resize();
//That2_Resize();
}
void
Stage_Init()
{
stage = clutter_stage_get_default( );
clutter_stage_set_color( CLUTTER_STAGE( stage ), CLUTTER_COLOR_Gray );
clutter_stage_set_user_resizable( CLUTTER_STAGE( stage ), TRUE );
clutter_actor_set_size( stage, 800, 600 );
clutter_actor_set_position( stage, 0, 0 );
clutter_stage_set_title( CLUTTER_STAGE( stage ), "Test resizing window while animation is playing" );
}
void
Stage_Signals_Init()
{
g_signal_connect( stage, "destroy", G_CALLBACK( clutter_main_quit ), NULL );
g_signal_connect( stage, "allocation-changed", G_CALLBACK( on_Stage_Resized ), NULL );
}
gint
main(int argc, char *argv[])
{
gint nReturn = 0;
// - initialization -
clutter_init( &argc, &argv );
Stage_Init();
Rectangles_Init();
Rectangle_Animation_Init();
// - signals -
Stage_Signals_Init();
Rectangle_Animation_Signals_Init();
// show Stage. Has to be called here, and not in Stage_Init()
clutter_actor_show( stage );
// - main loop -
clutter_main();
// - cleanup -
Rectangle_Animation_Destroy();
//This1_Destroy();
//That1_Destroy();
//Stage_Destroy();
return nReturn;
}
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list