tph@cs.utexas.edu (Pow-Hwee Tan) (03/11/91)
Greetings, Does anyone know the innards of the main event loop in the "run" method of Application class? I am trying to override the run method in my Application subclass. Specifically, I would like a routine I wrote to be called each time through the main event loop. I have tried using DPSAddTimedEntry with an interval of 0, but the animation done by the routine called is still jerky. While the 'jerkiness' may not be avoided totally with a heavy load, I would still prefer a more direct call from the main event loop to my routine. I have also tried overriding sendEvent, but sendEvent is not called when there is no event. Thanks in advance for any help. -- ph tan tph@cs.utexas.edu
izumi@fugitive.berkeley.edu (Izumi Ohzawa) (03/11/91)
In article <228@qt.cs.utexas.edu> tph@cs.utexas.edu (Pow-Hwee Tan) writes: > > Specifically, I would like a routine I wrote to be called each time >through the main event loop. I have tried using DPSAddTimedEntry with an >interval of 0, but the animation done by the routine called is still jerky. >While the 'jerkiness' may not be avoided totally with a heavy load, I would >still prefer a more direct call from the main event loop to my routine. Apologies if you know this already, but do you have NXPing(); in the method that is called each time the TimedEntry is executed? That is the standard way to fix 'jerkiness' problems with animation. Windowserver normally buffers DPS code sent to it, and executes it in bursts causing jerkiness. Overriding 'run' methond may not fix anything if the jerkiness is due to windowserver buffering. NXPing() essentially flushes the buffer and blocks until the piece of DPS code sent to the windowserver is executed. -- Izumi Ohzawa [ $@Bg_78^=;(J ] USMail: University of California, 360 Minor Hall, Berkeley, CA 94720 Telephone: (415) 642-6440 Fax: (415) 642-3323 Internet: izumi@violet.berkeley.edu NeXTmail: izumi@pinoko.berkeley.edu
sstreep@next.com (Sam Streeper) (03/12/91)
In article <228@qt.cs.utexas.edu> tph@cs.utexas.edu (Pow-Hwee Tan) writes: > Does anyone know the innards of the main event loop in the "run" method >of Application class? I am trying to override the run method in my >Application subclass. > > Specifically, I would like a routine I wrote to be called each time >through the main event loop. I have tried using DPSAddTimedEntry with an >interval of 0, but the animation done by the routine called is still jerky. >While the 'jerkiness' may not be avoided totally with a heavy load, I would >still prefer a more direct call from the main event loop to my routine. You really don't want to override run. The jerkiness is not caused by the event loop, it is the result of your messages to the window server getting queued up, and then flushed all at once. To avoid this, use NXPing() after each animation frame. NXPing() forces the queue to get flushed, and you should get a smooth and fairly constant frame rate. You'll still want/need to make realtime corrections for system load, but that's another issue, unrelated to the jerkiness problem. -sam
gessel@ilium.cs.swarthmore.edu (Daniel Mark Gessel) (03/13/91)
In article <1991Mar11.080607.26410@agate.berkeley.edu> izumi@fugitive.berkeley.edu (Izumi Ohzawa) writes: In article <228@qt.cs.utexas.edu> tph@cs.utexas.edu (Pow-Hwee Tan) writes: > > Specifically, I would like a routine I wrote to be called each time >through the main event loop. I have tried using DPSAddTimedEntry with an >interval of 0, but the animation done by the routine called is still jerky. >While the 'jerkiness' may not be avoided totally with a heavy load, I would >still prefer a more direct call from the main event loop to my routine. Apologies if you know this already, but do you have NXPing(); NXPing() is critical, but check out the BreakApp code. It creates it's own main loop and peeks at the next event. If there's nothing critical, it knows it can keep on drawing without haveing to handle an event. If there's an event it doesn't know what to do with, it get's out of the loop and let's the app handle it. This seems a really clean way to deal with tightening up an animation loop, although NXPing is what you really need for the jerkiness. See the BreakApp code for more info . . . Dan -- Daniel Mark Gessel Internet: gessel@cs.swarthmore.edu I do not speak (nor type) representing Swarthmore College.