Re: OpenGL 3D gears demo for Ruby
by Ilmari Heikkinen other posts by this author
May 2 2005 1:35PM messages near this date
OpenGL 3D gears demo for Ruby
|
Re: Cloning into an object
su, 2005-05-01 kello 09:02, Arto Bendiken kirjoitti:
> Hi there,
> The results were a bit surprising, in a good way. On my Linux computer
> with ATI Radeon 9700, the compiled version of the original gears.c
> gives an average 1271 FPS, whereas the gears.rb version achieves an
> average of 1203 FPS. (Both programs were run for a couple of minutes
> and results averaged.) That's only a 6% gap in performance.
Hello,
The reason the Ruby version runs fast is because the gears-program uses
display lists and hence the draw function is pretty much limited just by
the speed of OpenGL's display list drawing efficiency.
I did a couple of experiments comparing drawing the gears with and
without display lists and got the following results:
C, using display lists: 3321FPS
Ruby, using display lists: 3033FPS
C, without display lists: 2417FPS
Ruby, without display lists: 90FPS
The 27x speed difference sounds about right..
The gear function could probably be optimized by minimizing the amount
of Ruby math there and doing as much as possible with GL.Translate and
GL.Rotate, since the GPU does those (and fast!).
It's definitely possible to use Ruby for writing GL apps, though good
performance requires doing things in a way that uses GL's
performance-helping things as much as possible (HW T&L, vertex arrays,
display lists, or even writing inner loops and math-intensive parts in
C).
Anxiously waiting for the fast VM(s), :)
Ilmari
Thread:
Arto Bendiken
Ilmari Heikkinen
|