views:

310

answers:

3

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

GOSU (using ruby-opengl + gosu) 46Fps : alt text

RUBYGAME (using ruby-opengl + rubygame + rsdl) 32Fps : alt text

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 ?

+2  A: 

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.

Paul Sasik
I agree but the gap is huge :) Is there a better framework to do 2d (or 3d) graphics in realtime on ruby ?
XPac27
A: 

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.

Leonid Shevtsov
It's quite common for a framework to be doing a lot of work for you that you'd need to do yourself. So you'll see an initial slowdown like this, but when you start adding your game code you may not see much further slowdown as it efficiently uses the framework to get tasks done.
Kylotan
You want to move 1000 images on screen all at once? even if you do you'll still get 45 FPS. That's not bad at all.
banister
A: 

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

rtra
Nope, I'm using the ruby 1.8.1 (mac). But it looks like it's the best solution: http://programmingzen.com/2010/07/19/the-great-ruby-shootout-july-2010/Maybe the issue comes from the fact that Rubygame is based on SDL.
XPac27
If you're on mac, take a look a http://www.macruby.org/.
Mk12