Re: building OpenGL under GTK+ using gtkgl



Dov B. Kruger wrote:
I have a framework that is working well under GTK+, but there are a number of problems. Most critical, I need to know how to continuously busy-wait and force redrawing. I am currently using gtk_main() which sleeps and refreshes only when the screen is resized. Instead I assume I should do something like:

while (true) {
    while (gtk_main_iteration_do (TRUE))
       ;

    //then force a redraw (which is what I'm asking)

}

I cannot use a timing function as OpenGL is not threadsafe, and in any case to maximize performance, I simply want to loop as fast as possible, polling for input each time.

if there are no pending animations, then I can go back to sleeping until the next input event.

Hmmm, personally I would use an idle handler to draw frames while
the animation is playing; return FALSE when the animations are done
and re-queue the idle handler when a new animation is pending.

although I couldnt really tell you which way is faster: using an
idle handler run from the main loop whenever the app is idle... or
recursing into the main loop from some `while (1)' code.


Second, though less critical, the screen does not refresh when I maximize. What call do I need to trap that?

Not sure I understand; if you're not writing your own widget
implementation then the widget you are drawing on should get
resized and continue to recieve expose events when resized/maximized
automatically.

If you need to know when a window is resized you can connect to
"configure-event" on `that widget'.

Cheers,
                   -Tristan



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