drawInRect:glkView的区别和glkViewControllerUpdate:? OpenGL ES的2 - 的iOS [英] Difference between glkView:drawInRect: and glkViewControllerUpdate:? OpenGL ES 2 - iOS

查看:1523
本文介绍了drawInRect:glkView的区别和glkViewControllerUpdate:? OpenGL ES的2 - 的iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该是什么区别,目的明智的,在我的渲染循环这两种方法?

What should be the difference, purpose wise, between these two methods in my render loop?

苹果这样说的......

Apple has this to say....

关于update() 视图控制器调用其委托的glkViewControllerUpdate:方法。您的代理应更新的帧数据不涉及的结果呈现在屏幕上。

About update() The view controller calls its delegate’s glkViewControllerUpdate: method. Your delegate should update frame data that does not involve rendering the results to the screen.

关于drawInRect: 的GLKView对象,使得其OpenGL ES的背景下,当前的背景和它的帧缓冲结合为OpenGL ES的渲染命令的目标。你的委托方法应该再画视图的内容。

About drawInRect: the GLKView object makes its OpenGL ES context the current context and binds its framebuffer as the target for OpenGL ES rendering commands. Your delegate method should then draw the view’s contents.

因此​​,基本上,当我在我看来控制器上创建GLKView,该控制器将成为啦免费统计,所以我在看这些方法相映成趣。

So basically, when I create a GLKView in my view controller, that controller becomes the delate, so I am looking at these methods side by side.

我以为,更新()应该包含任何变换或其它逻辑。

I assumed that update() should contain any transforms or other logic.

推荐答案

在一审中,苹果公司正试图帮助你从帧速率脱钩时机。如果您的游戏总是设法拉拢分配给单个帧的时间框架,这两个会发生步调一致。但是,即使大量的对象来在屏幕上,你的帧速率下垂一点,你还是会得到更新相同数量的第二个这样的对象也将移动以相同的速度。

In the first instance, Apple are trying to help you decouple timing from frame rate. If your game always manages to draw a frame in the time allotted for a single frame, the two will occur in lockstep. But even if lots of objects come on screen and your frame rate sags a little, you'll still get the same number of updates a second so objects will still move at the same speed.

在第二,它可以帮你保持你的code分为模型 - 视图 - 控制器。如何使你的对象是presented应该从他们如何行动脱钩。

In the second, they're helping you keep your code divided as model-view-controller. How your objects are presented should be decoupled from how they act.

所以,你应该更新进度不管它是什么导致你的动画,你的画应该​​present的当前状态。

So your update should progress whatever it is that causes your animation, your draw should present the current state.

这篇关于drawInRect:glkView的区别和glkViewControllerUpdate:? OpenGL ES的2 - 的iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆