0

I wonder if there is a time function in apples SDK that is guaranteed to be monotonically increasing? I heard about [NSDate timeIntervalSinceReferenceDate] (which isn't accurate) and the c function mach_absolute_time.

How do all these people timing their animations in openGL ES (is there a frame independent solution)?

Constantin
  • 8,721
  • 13
  • 75
  • 126

3 Answers3

2

See this question: How can I get a precise time, for example in milliseconds in objective-c?

Community
  • 1
  • 1
nornagon
  • 15,393
  • 18
  • 71
  • 85
1

I use CADisplayLink to timing my animation. When you create a new opengl-es project on xCode, it will give you an sample opengl-es codes, and it control animation by CADisplayLink.alt text

EDIT:

I found I misunderstand this problem. I check the CFAbsoluteTimeGetCurrent() method on this apple on-line doc, and it said the method may be not monotonically increasing. And the method CACurrentMediaTime() which I prefered derived value by mach_absolute_time(). The document about CACurrentMediaTime() is on this link.

AechoLiu
  • 17,522
  • 9
  • 100
  • 118
1

For frame-rate-independent time, I generally use the CFAbsoluteTimeGetCurrent() function. It returns a CFAbsoluteTime (which I believe is typedef'd to double) since some date arbitrarily far in the past.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131