iOS - CADisplayLink

Previous topic - Next topic

theprotocol

Hi there,

I've noticed the refresh rate is quite jerky on iPhone, which is a bit disappointing since I've been working so hard to optimize my game (running at a constant 55fps). At 55 fps it feels out of sync with the screen refresh rate.

I've done research and found 2 solutions:

1. Motion interpolation - basically, the rendering method generates intermediate frames while waiting for the (slow) logic method to progress the game state.

It looks amazingly smooth, but it makes collisions a bit sloppy and I'm not sure if I want to keep it.

2. I've found this: http://gamedev.stackexchange.com/questions/2381/how-can-i-improve-the-smoothness-of-a-2d-side-scrolling-iphone-game

CADisplayLink to manage the game loop.


My question pertains to #2 - is there any way to expose CADisplayLink to GLBasic? I'm quite versatile with programming, but I absolutely can't wrap my head around Objective-C (if you ask me, obj-c is a "wrong" programming language design), so I'm at a bit of a loss here.

The idea is that using CADisplayLink as a timer would somehow synchronize SHOWSCREEN with the iPhone's native refresh, thus eliminating jerkiness (the link above shows that it can work).

I'd appreciate it if anyone could help me figure this out. Thanks in advance. :)

bigsofty

"CADisplayLink" would need an answer from Gernot.

Personally I would go for Motion Interpolation as it would automatically scale better across devices and handle any random slowdowns better than a fixed frame rate, esp. important on any true multitasking (non-iOS) platform.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spicypixel

I have 3 layers of parallax running at 60fps on my iPhone 3GS 8 way scrolling, smooth as can be. It doesn't need other solutions to get things smooth GLB is fast enough as is surely????
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

theprotocol

Quote from: spicypixel on 2012-Feb-21
I have 3 layers of parallax running at 60fps on my iPhone 3GS 8 way scrolling, smooth as can be. It doesn't need other solutions to get things smooth GLB is fast enough as is surely????

IPhone 4 is fillrate limited though. It has the same fillrate as 3GS but double the resolution (so, twice the workload of pixels). You can fill the screen at 60fps on an iPhone 4, but as soon as you add anything more on top of that, you're losing fps due to overdraw. Even the menus in my game run at ~54fps since I added button graphics.

I agree however that GLBasic is fast enough, if you make the right optimizations. However is it synchronized well enough? That's what I'm hoping to find out. In my experience, even locking it at 30fps felt "jerky" on iPhone.


@bigsofty: You're probably right. Interpolation also lets you reduce logic computation a bit. I've lowered the logic  from 50Hz/no interpolation to 30Hz+ rendering interpolation, and the latter feels much smoother. My only worry about this is a bit subjective. It all feels sloppy to me. I might need to get over that though. :)

spicypixel

I agree that locking at 30fps just seems jerky especially when loads of apps are at 30fps and still seems smooth. I understand what you mean about double resolution in the same way if you doing stuff fo iPad it's higher still. I am coding on the premise if it's fine on a lower resolution and presumably slower cpu model of iDevice and the higher models of device can't run it as well then that's not really something I'll concern myself with (I should probably) but if Apple bring out a device that will run slower due to them increasing screen size and not competently improving the CPU then that's not something I'm gonna worry about. Or at least I shouldn't have to.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.