为什么 ruby​​game 和 gosu 比纯 opengl 慢?

发布于 2024-08-12 12:24:26 字数 881 浏览 2 评论 0原文

我正在寻找一个好的图形框架来用 Ruby 制作一个漂亮的 2D 游戏。我做了 3 个非常简单的测试,看看 GosuRubygame。该测试创建了 1000 个“Square”类的实例,这些实例使用框架的方法以最简单的方式移动和绘制红色正方形。第三个测试是同样的事情,但是是在纯 OpenGL 实现中(没有任何框架)。这是结果:

PURE OPENGL(使用 ruby​​-opengl)80Fps: 替代文本 http://grab.by/JTM

GOSU(使用 ruby​​-opengl + gosu)46Fps : alt text http://grab.by/JTC

RUBYGAME(使用 ruby​​-opengl + ruby​​game + rsdl) 32Fps : alt text http://grab.by/JTw

为什么纯OpenGL测试的fps差异这么大以及 Rubygame 或 Gosu 测试? (他们都使用opengl)

这些框架真的可靠吗?或者我应该使用更好的框架吗? (我不认为自己会经历在纯 OpenGL 中加载图像、声音和字体的整个过程:p)

您有何看法?

I'm looking for a good graphic framework to make a nice 2D game in Ruby. I made 3 very simple test to see which graphic Ruby framework is faster between Gosu and Rubygame. The test creates 1000 instances of a "Square" class that move and draw a red square by the simplest way using the framework's method. The 3rd test is the same thing but in a pure OpenGL implementation (without any framework). Here is the results :

PURE OPENGL (using ruby-opengl) 80Fps :
alt text http://grab.by/JTM

GOSU (using ruby-opengl + gosu) 46Fps :
alt text http://grab.by/JTC

RUBYGAME (using ruby-opengl + rubygame + rsdl) 32Fps :
alt text http://grab.by/JTw

Why is there such a big fps difference between the pure OpenGL test and the Rubygame or Gosu test ? (has they both use opengl)

Are those framework really reliable or is there a better framework I should use ? (I don't see myself going through the whole process of loading images sounds and fonts in pure OpenGL :p)

What's your opinion?

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

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

发布评论

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

评论(4

伤痕我心 2024-08-19 12:24:26

当您使用框架时,任何用于简化和加速开发的框架都会立即导致性能损失。 OpenGL 是一个优秀且快速的库,但是当您使用高级语言和框架(如 Ruby)包装它时,您绝对可以预期速度会变慢。 OpenGL 仍然很快,你的缓慢来自于这些框架内发生的任何事情的开销。尽管如此,46 fps 看起来并不算太糟糕,但如果您要对引擎施加比您的示例更大的压力,您最终可能会得到一个无法玩的游戏。

When you use a framework, any framework to simplify and speed up development you immediately incur a performance penalty. OpenGL is a good and fast library but when you wrap it with a high level language and framework like Ruby you can absolutely can expect a slow down. OpenGL is still fast, your slowness comes from the overhead of whatever is going on inside those frameworks. Still, 46 fps doesn't seem too bad but if you're going to stress the engine much more than your example you might end up with a game that's not playable.

宁愿没拥抱 2024-08-19 12:24:26

我刚刚使用 Ruby 1.9.2 和 Gosu 制作了一个方形项目。我能够在 MacBook Pro 上获得 1000 个方块和 60 fps,而没有出现性能问题。使用 eval 展开我的对象数组,我在 60 fps 下得到了 4000 个方块。
这些方块具有随机速度并从显示器边缘反弹。

I just made a square project using Ruby 1.9.2 and Gosu. I was able to get 1000 squares and 60 fps without performance issues on my MacBook Pro. Using eval to unroll my object array i got 4000 squares at 60 fps.
The squares have a random speed and bounce off the edge of the monitor.

辞别 2024-08-19 12:24:26

如果这就是使用框架的惩罚,那么我想知道实际实现游戏逻辑的惩罚是什么……我对使用 Ruby 进行游戏开发的希望落得更快了。

If that's the penalty of using a framework, I wonder what's the penalty for actually implementing game logic... My hopes for using Ruby for gamedev are sinking even faster.

一曲爱恨情仇 2024-08-19 12:24:26

你在使用 YARV 吗?您应该尝试替代的 ruby​​ 实现,例如 jruby 或 rubinius。

Are you using YARV? You should try an alternative ruby implementation, like jruby or rubinius.

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