6

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?

XPac27
  • 301
  • 2
  • 8

4 Answers4

5

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
  • 79,492
  • 20
  • 149
  • 189
  • 1
    I agree but the gap is huge :) Is there a better framework to do 2d (or 3d) graphics in realtime on ruby ? – XPac27 Nov 23 '09 at 18:23
2

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.

Arrow
  • 221
  • 2
  • 3
0

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
  • 14,024
  • 9
  • 51
  • 82
  • 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 Nov 24 '09 at 11:03
  • 1
    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. – horseyguy Oct 03 '10 at 07:39
0

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

rtra
  • 1
  • 1
  • 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 Jul 20 '10 at 08:40