views:

245

answers:

1

I have an OpenGL application which is rendering intensive and also fetches stuff over HTTP.

Following Apple's samples for OpenGL, I originally used NSTimer for my main painting loop, before finding out (like everyone else) that it really isn't a good idea (because you sometimes have huge delays on touch events being processed when slow paints cause paint timers to pile up).

So currently I am using the strategy given by user godexsoft at http://www.idevgames.com/forum/showthread.php?t=17058 (search for the post by godexsoft). Specifically, my render run loop is on the main thread and contains this:

while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.01f, FALSE) == 
     kCFRunLoopRunHandledSource);

This line allows events like touch events and things related to comms to happen in between rendering of frames. It works, but I'd like to refine it further. Is there any way I can give priority to the touch events over other events (like comms related stuff)? If I could do that, I could reduce the 0.01f number and get a better frame rate. (I'm aware that this might mean comms would take longer to get back, but the touch events not lagging is pretty important).

A: 

This doesn't directly answer your question, but have you considered using CADisplayLink for scheduling redraws? It was introduced in iPhone OS 3.1.

codelogic
Hi there,yes, I've heard of CADisplay link, it sounds really handy! Unforuntately it can't be applied for the product I'm working on (need OS3.0 compatability). Thanks!
lexh