Its my first post . Any mistake , please bear with me .
I am new to iPhone development . I was using CADisplayLink to execute "Update" loop of my game . In XCode 8.2 I am using following code to calculate deltaTime between two consecutive frames .
Inside my AppDelegate.mm file
{
mDisplayLink = [CADisplayLink displayLinkWithTarget: self selector:@selector(gameLoop)];
mDisplayLink.preferredFramesPerSecond = 60 ;
[mDisplayLink addToRunLoop :[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
}
Inside my gameLoop() function
{
if (mDisplayLink==NULL) return;
mApp->CoreLoopUpdate((double)mDisplayLink.timestamp );
}
Inside my CoreLoopUpdate( double timeStamp) function
{
mDeltaTime = timestamp - mLastTimeStamp ;
if( mGame->IsInitialized() )
{
Update( mDeltaTime );
PreRender( mDeltaTime );
Render( mDeltaTime );
}
mLastTimeStamp = timestamp ;
std::cout<<"\nFPS : " << 1.0/mDeltaTime ;
}
It was printing correct fps ( 29 - 30 ) in my old system ( mac book pro , OS - Yosemite , XCode 7.1 ). When I upgraded my system (OS - Sierra , XCode - 8.2 ) , the value is not proper . It varies drastically between ( 2 fps to 30 fps ) which spoils my game play .
I have also implemented a variation to my deltaTime calculation according to http://www.gamasutra.com/blogs/KwasiMensah/20110211/88949/Game_Loops_on_IOS.php#note9 . But it did not solve the issue .
Any suggestion will be helpful .