I'm using CADisplayLink
on an iOS app with a renderOneFrame
method/handler. My understanding is this is triggered every screen refresh, i.e. 60Hz.
However my app is struggling to run at 60FPS and with more features to add, I worry that on older hardware this isn't feasible. Rather than have it running at variable rate, I'd rather render at 30FPS and give myself more breathing room.
Is there a way to make this happen easily?
This seems to be the core of it, but I'm a C++ coder porting to iOS so it's a bit confusing (I copied it from a sample I found):
- (void)go {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
mLastFrameTime = 1;
mStartTime = 0;
try {
app = new MyApp()
} catch( Ogre::Exception& e ) {
std::cerr << "An exception has occurred: " <<
e.getFullDescription().c_str() << std::endl;
}
mDate = [[NSDate alloc] init];
mLastFrameTime = -[mDate timeIntervalSinceNow];
mDisplayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(renderOneFrame:)];
[mDisplayLink setFrameInterval:mLastFrameTime];
[mDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[pool release];
}