Re: [clutter] Problem with async
I fixed my code but I do not understand why none of textures displayed without action keyboard and mouse. Here is my code and I hope he does not need too;) PS: Sorry for my very bad English Tanks #include #include void load_finished ( ClutterTexture *texture, const GError *error, gpointer user_data) { clutter_actor_set_size (CLUTTER_ACTOR (texture), 100, 100); } int main(int argc, char **argv) { ClutterActor *stage; ClutterColor black = {0x00, 0x00, 0x00, 0xff}; g_thread_init (NULL); clutter_threads_init (); clutter_init (&argc, &argv); // Stage stage = clutter_stage_get_default(); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Async"); clutter_actor_set_size (stage, 400, 400); // Load texture GError *error = NULL; const gchar *directory_path = "../cover"; GDir* directory = g_dir_open(directory_path, 0, &error); if (error) { g_warning("g_dir_open() failed: %s\n", error->message); g_clear_error(&error); return 0; } const gchar* filename = NULL; int x = 0, y = 0; while ((filename = g_dir_read_name(directory))) { if (g_str_has_suffix(filename, "png")) { gchar* path = g_build_filename (directory_path, filename, NULL); ClutterActor *image; printf("file: %s, x: %i\n", path, x); image = clutter_texture_new (); clutter_texture_set_load_async (CLUTTER_TEXTURE (image), TRUE); clutter_container_add (CLUTTER_CONTAINER (stage), image, NULL); clutter_actor_set_position (CLUTTER_ACTOR (image), x, y); // Connect load finished and set texture file g_signal_connect (image, "load-finished", G_CALLBACK (load_finished), NULL); clutter_texture_set_from_file (CLUTTER_TEXTURE (image), path, NULL); x += 15; y += 15; g_free (path); } } clutter_actor_show (stage); clutter_main(); return 0; } Le 11 nov. 09 à 16:16, Emmanuele Bassi a écrit : On Wed, 2009-11-11 at 14:56 +0100, Vincent Lauria wrote: void load_finished ( ClutterActor *image, GParamSpec *args1, gpointer data) { printf("load_finished()\n"); clutter_actor_set_size (image, 100, 100); } the signature for this signal is wrong. please, check the documentation. int main(int argc, char **argv) { ClutterActor *stage; ClutterColor black = {0x00, 0x00, 0x00, 0xff}; clutter_init (&argc, &argv); g_thread_init (NULL); this is wrong. the order for calling g_thread_init() is important. the correct order is: g_thread_init (NULL); clutter_threads_init (); clutter_init (&argc, &argv); image = clutter_texture_new (); clutter_texture_set_filter_quality ((ClutterTexture *) image, CLUTTER_TEXTURE_QUALITY_MEDIUM); Medium is already the default. clutter_texture_set_load_async ((ClutterTexture *) image, TRUE); don't use C casting: use the proper macros. for reference on threading, please see: tests/interactive/test-threads.c; for reference on asynchronous loading, please see: tests/interactive/test-texture-async.c ciao, Emmanuele. -- To unsubscribe send a mail to clutter+unsubscr...@o-hand.com -- To unsubscribe send a mail to clutter+unsubscr...@o-hand.com
Re: [clutter] Problem with async
On Wed, 2009-11-11 at 14:56 +0100, Vincent Lauria wrote: > void > load_finished ( > ClutterActor *image, > GParamSpec *args1, > gpointer data) > { > printf("load_finished()\n"); > clutter_actor_set_size (image, 100, 100); > } the signature for this signal is wrong. please, check the documentation. > int main(int argc, char **argv) > { > ClutterActor *stage; > ClutterColor black = {0x00, 0x00, 0x00, 0xff}; > > clutter_init (&argc, &argv); > g_thread_init (NULL); this is wrong. the order for calling g_thread_init() is important. the correct order is: g_thread_init (NULL); clutter_threads_init (); clutter_init (&argc, &argv); > image = clutter_texture_new (); > clutter_texture_set_filter_quality ((ClutterTexture *) > image, > CLUTTER_TEXTURE_QUALITY_MEDIUM); Medium is already the default. > clutter_texture_set_load_async ((ClutterTexture *) > image, TRUE); don't use C casting: use the proper macros. for reference on threading, please see: tests/interactive/test-threads.c; for reference on asynchronous loading, please see: tests/interactive/test-texture-async.c ciao, Emmanuele. -- To unsubscribe send a mail to clutter+unsubscr...@o-hand.com
[clutter] Problem with async
Hello everyone, I have a little problem with the function clutter_texture_set_load_async. Nothing is displayed unless a timer is triggered or action keyboard or mouse is sent, here is my code: #include #include void load_finished ( ClutterActor *image, GParamSpec *args1, gpointer data) { printf("load_finished()\n"); clutter_actor_set_size (image, 100, 100); } int main(int argc, char **argv) { ClutterActor *stage; ClutterColor black = {0x00, 0x00, 0x00, 0xff}; clutter_init (&argc, &argv); g_thread_init (NULL); // Stage stage = clutter_stage_get_default(); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Async"); clutter_actor_set_size (stage, 400, 400); // Load texture GError *error = NULL; const gchar *directory_path = "../cover"; GDir* directory = g_dir_open(directory_path, 0, &error); if (error) { g_warning("g_dir_open() failed: %s\n", error->message); g_clear_error(&error); return 0; } const gchar* filename = NULL; int x = 0, y = 0; while ((filename = g_dir_read_name(directory))) { if (g_str_has_suffix(filename, "png")) { gchar* path = g_build_filename (directory_path, filename, NULL); ClutterActor *image; printf("file: %s, x: %i\n", path, x); image = clutter_texture_new (); clutter_texture_set_filter_quality ((ClutterTexture *) image, CLUTTER_TEXTURE_QUALITY_MEDIUM); clutter_texture_set_load_async ((ClutterTexture *) image, TRUE); clutter_actor_set_position (image, x, y); clutter_container_add (CLUTTER_CONTAINER (stage), image, NULL); // Connect load finished and set texture file g_signal_connect (image, "load-finished", G_CALLBACK (load_finished), NULL); clutter_texture_set_from_file ((ClutterTexture *) image, path, NULL); x += 15; y += 15; g_free (path); } } clutter_actor_show (stage); clutter_main(); return 0; } -- To unsubscribe send a mail to clutter+unsubscr...@o-hand.com