[英]Best way to time an OpenGL animation on OSX/iPhone
我一直在Mac上使用特定于Mac的OpenGL API在OpenGL上进行实验,创建精确动画循环的最佳方法是什么?
Use GLKit which is available since iOS 5 and takes away a lot boiler plate code you usually have to write for yourself. 使用自iOS 5开始提供的GLKit,并且您需要自己编写很多锅炉板代码。 Particularly the game/animation loop stuff is handled by the framework.
特别是游戏/动画循环的内容是由框架处理的。 Basically you have to implement some delegate methods:
基本上,您必须实现一些委托方法:
GLKViewControllerDelegate for updating vertices etc.: GLKViewControllerDelegate用于更新顶点等:
- (void)glkViewControllerUpdate:(GLKViewController *)controller
GLKViewDelegate fro drawing: GLKViewDelegate来回绘图:
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
On the Mac side you're probably used to using CVDisplayLink
to synchronise with the vertical retrace. 在Mac方面,您可能习惯使用
CVDisplayLink
与垂直回扫同步。 The iOS equivalent is CADisplayLink
— it's basically the same functionality but responsibility is given to CoreAnimation rather than CoreVideo and the syntax differs slightly. 与iOS等效的是
CADisplayLink
,它基本上是相同的功能,但是责任由CoreAnimation而不是CoreVideo承担,语法略有不同。
If you are willing to target iOS 5 exclusively then Kai's advice is probably best. 如果您愿意专门针对iOS 5,那么Kai的建议可能是最好的。 Just use one of GLKit's new view controllers and all the stuff related to creating and wiring up a display link is handled for you.
只需使用GLKit的新视图控制器之一,即可为您处理与创建和连接显示链接有关的所有内容。
Well, I have no experience with mobile dev, but I guess the idea is the same as on a PC. 好吧,我没有移动开发人员的经验,但是我想这个想法与PC上的想法相同。 The keyframe interpolation of animated models should be done each time you render your scene (if necessary, of course).
动画模型的关键帧插值应该在每次渲染场景时进行(当然,如果需要的话)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.