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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With