Re: Best solution for game loop on OSX?
Re: Best solution for game loop on OSX?
- Subject: Re: Best solution for game loop on OSX?
- From: Eric Wing <email@hidden>
- Date: Tue, 17 Dec 2013 11:22:11 -0800
On 12/17/13, Uli Kusterer <email@hidden> wrote:
> On 17 Dec 2013, at 00:15, Dan Treiman <email@hidden> wrote:
>> The two best solutions (and by best I mean least time-wasting) are
>> CVDisplayLink and NSTimer.
>>
>> CVDisplayLink synchronizes with the display refresh rate and gives you
>> callbacks in a background thread. This somewhat like CADisplayLink on
>> iOS. Its pretty easy to do but your code must be thread-aware.
>>
>> NSTimer has more than enough resolution for games, and if you are using
>> OpenGL for graphics you should do: (…)
>
> He’s talking about OpenAL, not OpenGL. Audio, not graphics. So I don’t
> think the display links are a good choice here. They’re intended to avoid
> tearing when doing screen display, and depending on your screen and power
> saver settings may not get called as often as you’d want for sound.
So I'll put in my 2 cents since OpenAL is something I have a lot of
expertise in.
NSTimer generally works pretty well (and I was under the impression
that 10.9 timers are even more accurate now). Even though the firing
rate can be inconsistent, I don't think you need a lot of precision
for spatial audio. I've never been exposed to an audio system and been
in a situation where I could discern the difference between audio
points only a tiny distance away from each other.
The problem I've had with CVDisplayLink in the past is when the
window/view disappears for certain reasons (I can't remember...was it
user minimizing, or what), the display link callbacks automatically
turn off. This is fine for graphics, but sucks if you are trying to
keep track of time elapsed or want to continue playing background
music. (I haven't experienced this problem with CADisplayLink on iOS.)
Thanks,
Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden