在iPhone中将OpenGL与UIKit混合使用时,确切的性能成本是多少? [英] What is the exact performance cost when mixing OpenGL with UIKit in iPhone?

查看:77
本文介绍了在iPhone中将OpenGL与UIKit混合使用时,确切的性能成本是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对如何处理需要在图像纹理之上渲染少量3D对象的应用程序做出设计决策. 结果需要呈现并保存为UIImage. 图形设计(客户端)希望标准UIKit控件能够操纵3D世界.

I need to make a design decision of how to approach an app which needs to render few 3D objects on top of an image texture. Result needs to be rendered and saved as an UIImage. Graphical design (client) expects standard UIKit controls to manipulate 3D world.

OpenGL视图(CAEAGLLayer层)需要位于UIScrollView内,以实现廉价而自然的滚动和缩放实现. 只有很少的额外控件可以控制旋转比例和少数3D对象的过渡. 预期三角形(最多100-200个)和2-3个纹理(1个蒙版)的三角形不多.它甚至不必在某些转换和缩放更改时就不断刷新. CAEAGLLayer不必是不透明的.

OpenGL view (CAEAGLLayer layer) needs to be inside UIScrollView for cheap and natural scroll and zooming implementation. There are just few extra controls to manipulate rotation scale and transition of the few 3D objects. There is not many triangles expected (100-200 at most) and 2-3 textures (1 mask). It does not even have to be refreshed constantly, just when some transformations and zoom changes. CAEAGLLayer does not need to be opaque.

我会使用Core Animation解决方案,但是不支持将3D转换的CALayers渲染到CGContextRef(也不屏蔽).

I would go with Core Animation solution but rendering 3D transformed CALayers to CGContextRef is not supported (neither is masking).

将CAEAGLLayer放入UIScrollView并将其与少量UIKit视图混合时,实际的性能成本是多少? 我希望每秒能以平滑的帧速率(每秒30帧)渲染多少个三角形,这样我才能做出最好的决定?

What is real performance cost when putting CAEAGLLayer inside UIScrollView and mixing it with few UIKit views? How much triangles per second can I expect to be rendered with smooth frame rate (30fps will do), so I can make the best decision possible?

我知道已经有类似的问题,但是没有一个答案提供具体的数字,这可能有助于估计预期的渲染结果.

I know there are similar questions out there already, but none of the answers provides specific numbers, which could help with estimating expected rendering results.

推荐答案

在WWDC和WWDC上进行OpenGL演讲的艾伦·谢弗(Allan Schaffer)最重要的是要重新组合.我特别跟他谈过一个应用程序,该应用程序在实时更新的OpenGL视图下具有实时更新的视频视图,他说这种事情是最糟糕的情况.通常,在顶部放置一些非常静态的视图并不昂贵,例如使用UILabel在OpenGL游戏中显示当前得分.

Per Allan Schaffer, who gives the WWDC and WWDC on tour OpenGL speeches, OpenGL itself is not so much a special case — it's that anything that changes will cause everything on top of it to be recomposited. I spoke to him specifically about an app with a live updating video view underneath a live updating OpenGL view and he said that sort of thing is the pathological worst case. It's generally not that expensive to throw a few quite static views on top, such as using a UILabel to display the current score over an OpenGL game.

就您而言,我认为您可以在很大程度上避免此问题.不要将GL视图放在滚动视图中,而要使滚动视图不透明并将GL视图放在它的后面.捕获scrollViewDidScroll:(和相应的缩放消息)并进行相关的OpenGL调整.我可以根据经验说,我已经在iPad 1上做到了这一点,而没有任何性能问题.特别是对于您正在谈论的那种模型,我认为没有问题.

In your case, I think you can probably largely avoid the problem. Don't put the GL view inside the scroll view, but rather make the scroll view non-opaque and put the GL view behind it. Catch scrollViewDidScroll: (and the corresponding zoom messages) and make related OpenGL adjustments. I can speak from experience and say I've done exactly that on an iPad 1 with no performance issues. Particularly for the sort of model you're talking about I don't imagine a problem.

这篇关于在iPhone中将OpenGL与UIKit混合使用时,确切的性能成本是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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