[Haskell] GLUT gears speed

Sven Panne Sven.Panne at aedion.de
Sat Feb 18 13:55:04 EST 2006


[ Sorry for the extremely slow reply, I'm just working through a mail backlog 
of about one month... ]

Am Freitag, 6. Januar 2006 22:17 schrieb Wolfgang Jeltsch:
> what's the reason behind the HOpenGL gears only being about 2/3 as fast as
> glxgears on my computer?  Since I don't use any 3D acceleration, I thought
> that most of the CPU's time is spend for rendering and displaying so that
> speed differences between Haskell and C shouldn't matter that much.

An almost identical issue was discussed on the HOpenGL mailing list some time 
ago:

   http://www.haskell.org//pipermail/hopengl/2004-March/000476.html

The net result is: There is no measurable speed difference compared to plain 
old C when using Haskell + HOpenGL. Another nice project to look at:

   http://www.haskell.org//pipermail/haskell/2005-November/016941.html

Having said this, one should mention that there are plenty of reasons for 
bottlenecks when doing graphics in OpenGL in general: The application 
performance can be limited by the CPU, memory bandwidth, the GPU on the 
graphics card, pixel bandwidth, etc. The least thing I would worry about 
would be Haskell or the HOpenGL package. :-)

Rendering terrain efficiently is a rather tricky topic, so one can find tons 
of books and papers on it, and I guess it still has enough potential to give 
material for several PhD dissertations. If your students are new to Haskell, 
OpenGL and terrain rendering algorithms, this might be a little bit too much 
IMHO.

Regarding documentation: The OpenGL package documentation is admittedly 
sometimes a bit terse, it ranges from no comments at all (i.e. only things 
that Haddock can generate automatically) to rather elaborate, e.g.:

http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL-GL-Points.html
http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL-GL-LineSegments.html

The OpenGL 1.5 spec is about 333 pages, and translating this into Haddock 
comments is a huge amount of work, so I comment only from time to time (a 
slow, but ongoing process). But the main idea here is that the OpenGL binding 
resembles the C API closely enough that everybody who knows the spec should 
have no problem at all writing OpenGL stuff in Haskell. Therefore the whole 
module structure and naming is designed to closely follow the spec, compare 
e.g.

http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL-GL.html

with the index of the OpenGL 1.5 spec. Furthermore, the GLUT package has quite 
a few examples to get everyone started. If there are still problems, there is 
still the hopengl list and I'll happily clarify any unclear points. The GLUT 
package is structured similarly, but fully documented:

http://www.haskell.org/ghc/docs/latest/html/libraries/GLUT/Graphics-UI-GLUT.html

In general, I think it is a good idea for any binding to follow the structure 
of the original spec as closely as possible.

Cheers,
   S.


More information about the Haskell mailing list