如何在 iPhone 上为 openGL 动画计时?

发布于 2024-10-12 11:57:18 字数 193 浏览 7 评论 0 原文

我想知道apples SDK中是否有一个保证单调递增的时间函数?我听说过 [NSDate timeIntervalSinceReferenceDate] (这不准确)和 c 函数 mach_absolute_time

所有这些人如何在 openGL ES 中计时他们的动画(是否有独立于帧的解决方案)?

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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

著墨染雨君画夕 2024-10-19 11:57:18

我使用 CADisplayLink 来计时我的动画。当您在 xCode 上创建一个新的 opengl-es 项目时,它会给您一个示例 opengl-es 代码,并通过 CADisplayLink 控制动画。alt text

编辑

我发现我误解了这个问题。
我检查此 apple在线doc,里面说该方法可能不是单调递增的。我更喜欢通过 mach_absolute_time() 导出值的方法 CACurrentMediaTime() 。关于 CACurrentMediaTime() 的文档是 此链接

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.

简单气质女生网名 2024-10-19 11:57:18

对于与帧速率无关的时间,我通常使用 CFAbsoluteTimeGetCurrent() 函数。它返回一个CFAbsoluteTime(我相信它的类型定义为double),因为某个日期是任意遥远的过去。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文