Re: Problem with gtk_widget_queue_draw()



Hi,

You must only draw in expose events. I think the way to structure your
program is:

- have a timeout 60 times a second (every 16ms)
- in the timeout, update the variables which control the display ...
for example, you might update the (x, y) positions of some objects
- at the end of the timeout function, call gtk_widget_queue_draw() to
trigger a repaint
- in your expose function, redraw the screen using the current values
of all your variables

You can make it a bit faster if you know that only part of the screen
needs to be repainted ... use gtk_widget_queue_draw_area().

It may not be perfectly smooth, since the gtk timeout functions are
not really right for realtime work. In this case, you could split your
program into two threads: have a background thread which updates the
variables every 16ms, and a foreground thread which repaints the
screen as quickly as it can.

On Wed, 20 Oct 2004 01:30:09 +0200 (CEST), simkin simkin
<simkintmp yahoo es> wrote:
Hi, this is my first mail :D

Sorry if my english is poor but i dont speak it and i
can't write it perfectly.

I was doing a gtk app for showing an armonic simple
movement. The interface was easy to do but when i
tryed to make the animation of the movement in a
drawingarea I found some problems. I created an extra
thread for the animation and put the gdk_draw's on it
but when i compiled it i realised that the pixmap
wasn't being updated. (i thought that gdk_draw calls
would make an expose_event). So, I tryed to solve this
problem by using gtk_widget_queue_draw to redraw the
drawingarea each time i needed but it don't works very
well. I want the DrawingArea to redraw sixty times
each second more or less but i cant make it since the
refresh with queue_draw() feels very slow, like 2
frames per sec :S
how can i solve this?
there is another way to get the same effect?

______________________________________________
Renovamos el Correo Yahoo!: ¡100 MB GRATIS!
Nuevos servicios, más seguridad
http://correo.yahoo.es
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]