Haskell homepage  +  OpenGL homepage OpenGL homepage  = HOpenGL 
haskell.org / hopengl

Home
Past, Present & Future
Releases
Documentation
.spec Files Explained
Mailing List
 


HOpenGL: An OpenGL/GLUT binding for Haskell

HOpenGL is a Haskell binding for the OpenGL graphics API (GL 1.2.1 / GLU 1.3) and the portable OpenGL utility toolkit GLUT. It is heavily tested under Linux (using Brian Paul's free OpenGL work-alike Mesa library) and under Windows. Among other things, it features strong typing, a more Haskell-like interface than the plain C-API, and consistent prefix-free naming of OpenGL functions and constants, see the acompanying README.

In addition to GLUT, future versions of HOpenGL may contain additional toolkits for user interaction like GLUI or PUI. HOpenGL can already be used with Manuel Chakravarty's GTK+ binding for Haskell.

Because some language extensions are used which are not yet standardized, HOpenGL is closely tied to the Glasgow Haskell Compiler for now, but this situation is likely to change in the near future. With a little work it can probably tweaked to work with Hugs and nhc98, but this has not been tested yet. Apart from that, it should be fairly portable, see the accompanying installation guide.

Here are screenshots for two examples from the famous Red Book, ported to Haskell: The first example shows the composition of modelling transformations, and the second example renders a lighted, filled Bezier surface using two-dimensional evaluators. For comparison, the original C sources are available below, too. Although extremely similar, the Haskell versions provide strong typing at compile time, making it, e.g. impossible to use a buffer name as a capability, which is all too easy in the C binding and most probably resulting in a runtime error. To learn more about the examples, you can browse through an older edition of the book online, either in HTML format or as a PDF.

planet example bezier mesh example
Planet.hs / planet.c BezMesh.hs / bezmesh.c

And here the real reasons for writing this API binding: :-)

Introduction The Prison G1za by g1zm0
start pk1 pk16
demon player zombie
Oh no, not him again! Flubber? Author during debugging

These are unmodified screenshots from HOpenGL programs. Note: Due to the inevitable loss in quality wheng using JPEG, there can be some strange artifacts in the above screenshots, especially on color depths below 24bpp.

And a final remark: Not surprisingly, the layout of the HOpenGL pages has shamelessly been stolen from www.opengl.org...  :-)
 

 

   
Home | Feedback | haskell.org