且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

结合的UIView动画块和OpenGL ES渲染

更新时间:2023-11-03 23:30:40

我设法解决这个问题,现在我可以在我的OpenGL游戏结合了基于块的UIView /核心动画没有任何性能下降。

I managed to solve the problem and now I can combine UIView block/core based animations in my OpenGL game without any performance drop.

解决的办法很简单:


  1. 对于在你的OpenGL应用程序所需的每个UIView的,保持它的界限,中心和你的OpenGL屏幕坐标系转换属性(如创建以下属性:GLBounds,GLCenter,GLTranform),并相应地更新他们时,你改变之一相应的UIView属性。

  2. 当你开始游戏,加载UIViews,但将它们设置为隐藏即可。因此,UIKit中的不画在OpenGL视图,(这样的丢帧问题是完全elliminated)的顶部。相反使用在步骤1中创建的GL *属性,并使用自己绘制的UIViews相应的纹理(您用于每个UIView的图像/色)。

  3. 使用取决于你想要达到的动画块/核心动画动画在隐藏 UIViews属性(边界,中心和转换)(这反过来又更新您的GL *属性),并在你的OpenGL平局方法使用GL *属性来绘制UIViews!要获取范围,中心的实际值,当一个UIView是动画变换(并更新GL *属性)使用其presentationLayer属性。

  1. For each UIView that you want in your OpenGL app, keep its bounds, center and transform properties in your OpenGL screen coordinate system (e.g. create the following properties: GLBounds, GLCenter, GLTranform) and update them accordingly whenever you change one of the corresponding UIView properties.
  2. When you start the game, load the UIViews but set them to hidden. So, UIKit does not draw on top of the OpenGL view (this way the frame drop issue is completely elliminated).Instead draw the UIViews yourself using the GL* properties you created in step 1, and using the corresponding textures (the images/colors you used for every UIView).
  3. Animate the hidden UIViews properties (bounds, center and transform) using block/core animation depending on the animation you want to achieve (which in turn updates your GL* properties) and in your OpenGL draw method use the GL* properties to draw the UIViews! To get the actual values for bounds, center and transform when a UIView is animating (and update the GL* properties) use its presentationLayer property.

***的,