Personal tools


From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(Added instructions on how to get depth buffer working for GLFW)
(Added a link to OGL)
Line 66: Line 66:
* [ OpenAL]: A binding to the [[OpenAL]] cross-platform 3D audio API
* [ OpenAL]: A binding to the [[OpenAL]] cross-platform 3D audio API
* [ ALUT]: A binding for the OpenAL Utility Toolkit
* [ ALUT]: A binding for the OpenAL Utility Toolkit
A fork of HOpenGL:
* [[OGL]]

Revision as of 14:09, 13 May 2009

This is a stub page for Haskell's OpenGL and GLUT bindings. It is meant as a starting point to replace the outdated and misleading documentation at the old page.

First, note that the implementation is far more up-to-date than that old page suggested (originally, it was quite useful, but the page hasn't kept up with the implementation for a long time now).


1 References

In particular, note that the examples/ directory in the GLUT repo contains lots of examples, including translations of the red book examples.

Both the API documentation and the examples are best studied with the original specs and the original red book examples at hand. An index of the examples from v1.1 of the red book, with screen shots, can be found here

2 Projects using the OpenGL bindings

  • Endless Cavern, a 2D procedurally-generated exploration game.
  • Frag, a 3D first-person shooter game.
  • Monadius, a 2D scrolling arcade game.
  • Roguestar, a roguelike adventure game using 3D graphics.
  • Shu-thing, a 2D scroling arcade game.
  • Topkata, a jumping ball puzzle game.
  • PolyFunViz, a toolkit for scientific visualization (e.g. surfaces, flows, contours, volumes)

3 HOpenGL Resources

4 OpenGL Resources

5 Getting Started

6 Additional software

  • FTGL: Portable TrueType font rendering for OpenGL using the Freetype2 library
  • GLFW: A binding for GLFW, An OpenGL Framework
  • GLUT: A binding for the OpenGL Utility Toolkit
  • graphics-drawingcombinators: A functional interface to 2D drawing in OpenGL

Somewhat related is SDL, which is also based on OpenGL:

To add sound to OpenGL applications:

  • OpenAL: A binding to the OpenAL cross-platform 3D audio API
  • ALUT: A binding for the OpenAL Utility Toolkit

A fork of HOpenGL:

7 Troubleshooting

7.1 I can't display text with renderString

It's probably because the text is displayed too big. Setting a much smaller scale factor before calling renderString should solve the problem.

scale 0.001 0.001 (0.001∷GLfloat)
renderString Roman "Test string"

7.2 Animations flicker

If you're not using DoubleBuffered display mode, turn that on. Also, you must set the display mode before creating the window you're going to be drawing in. To check if you've enabled double buffering use something like:

db <- get doubleBuffered

and set DoubleBuffered mode (before creating your windows!) like this:

initialDisplayMode $= [DoubleBuffered]
createWindow "My Window"
You will also need to call <div dir="ltr" class="mw-geshi mw-content-ltr">
at the end of your draw function.

7.3 The depth buffer doesn't work (things that are closer to the camera are occluded by things that are farther from the camera)

Make sure that depthFunc is set:

depthFunc $= Just Less

Furthermore, if you're using GLFW, the following var has to be greater than zero:

get (windowParam DepthBits)

If DepthBits is 0, you probably forgot to initialize the window, like so:

openWindow size [DisplayDepthBits 16] Window

Once you enable the depth buffer, you will need to clear it before each cycle of your drawing method:

clear [ColorBuffer, DepthBuffer]

See also: The OpenGL FAQ: 12.010 How do I make depth buffering work?