iPhone。粒子系统性能

发布于 2024-08-26 13:43:57 字数 242 浏览 8 评论 0原文

我尝试使用Core Graphics将雨和雪绘制为粒子系统。 在模拟器中渲染进行得很好,但是当我在真实设备上运行我的应用程序时,渲染速度变慢。

因此,请告诉我如何提高iPhone 上的粒子系统绘图性能

也许我应该使用 OpenGLCoreAnimation

I try to draw rain and snow as particle system using Core Graphics.
In simulator rendering proceeded fine but when I run my app on real device rendering is slow down.

So, advise me please approaches to increase particle system drawing performance on iPhone.

May be I should use OpenGL for this or CoreAnimation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痞味浪人 2024-09-02 13:43:57

OpenGL 将是渲染的最低级别,因此应该提供最佳性能(如果做得正确)。如果粒子数量不是太多,CoreAnimation 就足够接近了(确切的数字取决于其他因素,但最多 50 个左右就可以了)。
当你说你现在正在使用 CoreGraphics 时,你的意思是你正在根据计时器重绘吗?如果是这样,那么 CoreAnimation 肯定会帮助你 - 只要你可以将每个粒子分离到一个视图中。您仍然可以使用 CoreGraphics 来渲染各个粒子。

您是否使用物理引擎来计算位置?

OpenGL would be the lowest level to drop to for the rendering, so should offer the best performance (if done right). CoreAnimation would be close enough if there are not too many particles (the exact figure depends on other factors, but upto about 50 should be ok).
When you say you're using CoreGraphics at the moment do you mean you're redrawing based on a timer? If so then CoreAnimation will definitely help you out - as long as you can seperate out each particle into a view. You could still use CoreGraphics to render the individual particles.

Are you using a physics engine to calculate the positions?

音栖息无 2024-09-02 13:43:57

如果您只是使用 Core Graphics 绘制视图,然后每帧重新绘制它以反映粒子的运动,您将看到糟糕的性能(有关更多信息,请参阅 这个答案)。您将需要使用 OpenGL ES 或 Core Animation 来获取粒子系统动画。

我的建议是查看 CAReplicatorLayer,iPhone OS 3.0 和 Snow Leopard 中添加的新核心动画图层类型。我见过一些仅使用这一层类型创建的令人印象深刻的粒子系统,而无需使用太多代码。请参阅 ReplicatorDemo 示例应用程序(适用于 Mac,但核心概念是相同的),或者 Joe Ricioppo 的 "To 1e100f And超越 CAReplicatorLayer” 文章。

If you are simply drawing a view with Core Graphics, then redrawing it every frame to reflect the movement of the particles, you will see terrible performance (for more, see this answer). You will want to go to OpenGL ES or Core Animation for the particle system animation.

My recommendation would be to look at CAReplicatorLayer, a new Core Animation layer type added in iPhone OS 3.0 and Snow Leopard. I've seen some impressive particle systems created just using this one layer type, without using much code. See the ReplicatorDemo sample application (for the Mac, but the core concepts are the same), or Joe Ricioppo's "To 1e100f And Beyond with CAReplicatorLayer" article.

宛菡 2024-09-02 13:43:57

如果您的实施信息很少甚至没有,就很难提供建议。根据我的经验,iPhone 的主要瓶颈之一是内存分配。因此,如果您要为生成的每个粒子分配新对象,这将是您可能想要解决的第一件事。 (分配对象池并重用它们。)

It's hard to give advice with little to no information about your implementation. One thing that is a major bottleneck on the iPhone from my experience are memory allocations. So if you're allocating new objects for each particle spawned, that would be the first thing you might want to fix. (Allocate a pool of objects and reuse them.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文