Hello,
I have a simulation running in a drawing_area, I start this simulation with gtk_timeout_add (50, Repaint, da).
gint Repaint (gpointer data) { GtkWidget *da = (GtkWidget *) data; GdkRectangle update_rect; static double t = 0.0;
etc. etc. define graphics in pixmap and then repaint the window with the pixmap.
}
To get the timing I have defined a static double t = 0.0; which I let count with t +=t + 0.050; Then I can look up the correct value in a table for the given time.
This works okay, well the block move but not exactly at the right time. It does not work very accurate because I assume the function is called every 50 ms, but when I move my mouse around then that can not be quaranteed. It slows down the simulation.
My idea was to overcome this problem by calling clock() (using <time.h>) in Repaint. This does not work properly. The time seems to freeze, and only when I move my mouse around or drag the window the time is updated.
Why does clock() not work properly in this case and how can I overcome this problem ? Does anybody have experience with graphical simulations?
The source looks like this (inside Repaint)
static double t = 0; static double tstart;
ClockResult = clock(); if (t==0) tstart = (double) ClockResult / (double) CLOCKS_PER_SEC; t = (double) ClockResult / (double) CLOCKS_PER_SEC - tstart + 0.00001;
Thank you in advance for your help, Edward
_______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list