使用 CADisplayLink 强制重绘
我目前正在使用 CADisplayLink 来显示 OpenGL 动画,效果非常好。然而,有时参数发生变化,我需要立即重绘视图,而不能等到 CADisplayLink 请求下一帧。如果我不这样做,我就会得到一帧错误,这在我的情况下看起来非常糟糕。
那么,如何在不干扰 CADisplayLink
内容的情况下强制重绘 EAGLView
呢?
I'm currently using CADisplayLink
to show an OpenGL animation which works great. Sometimes, however a parameter changes and I need to redraw the view immediately and can't wait until the next frame is requested by CADisplayLink
. If I don't do that, I get one frame wrong which looks really bad in my case.
So, how can I force a redraw of an EAGLView
without interfering with the CADisplayLink
stuff?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
例如,如果您的 CADisplayLink 正在调用方法drawFrame,则只需在需要时自己调用drawFrame即可。如果您不愿意,则没有理由需要等待 CADisplayLink。
If your CADisplayLink is calling method drawFrame, for example, then just call drawFrame yourself when you need to. No reason you need to wait for CADisplayLink if you don't want to.
您的问题表明您将数据存储在视图中而不是数据对象中。您应该能够随时更改数据,并且您的视图应该在需要显示时更新。将数据移动到模型对象,并让
EAGLView
在 CADisplayLink 请求时根据数据自行绘制,而不是在数据更改时重新绘制自身。Your question suggests that you're storing your data in your view rather than in a data object. You should be able to change your data at any time, and your view should update when its needed to display. Move the data to a model object, and have the
EAGLView
draw itself based on the data when requested from theCADisplayLink
rather than redrawing itself when the data changes.