Why is rubygame and gosu slower than pure opengl?

I am looking for a good graphical structure to make a good 2D game in Ruby. I did 3 very simple tests to see which Ruby graphical structure is faster between Gosu and Rubygame . The test creates 1000 instances of the "Square" class, which move and draw a red square in the simplest way using the framework method. The third test is the same thing, but in a clean OpenGL implementation (without any frameworks). Here are 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 a pure OpenGL test and a Rubygame or Gosu test? (they both use opengl)

Are these frameworks really reliable or is there a better framework I should use? (I don’t see how I view the whole process of loading images of sounds and fonts in pure OpenGL: p)

What is your opinion?

+6
ruby opengl rubygame libgosu
source share
4 answers

When you use the framework, any framework to simplify and speed up development, you immediately get a performance penalty. OpenGL is a good and fast library, but when you complete it with a high-level language and framework like Ruby, you can absolutely expect a slow one. OpenGL is still fast, your slowness comes from the overhead of what happens inside these frameworks. However, 46 frames per second does not seem too bad, but if you are going to emphasize the engine much more than your example, you may find yourself in a game that does not play.

+5
source share

I just did a square project using Ruby 1.9.2 and Gosu. I was able to get 1000 squares and 60 frames per second without performance issues on my MacBook Pro. Using eval to expand my array of objects, I got 4,000 squares at 60 frames per second. The squares have a random speed and bounce off the edge of the monitor.

+2
source share

If this is a punishment for using the framework, I wonder what the penalty is for the actual implementation of game logic ... My hopes of using Ruby for gamedev are dropping even faster.

0
source share

Do you use YARV? You should try an alternative ruby ​​implementation like jruby or rubinius.

0
source share

All Articles