* [http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL.html the API docs for the OpenGL binding]

+

* Starting with 2013.2.0.0, the OpenGL packages are part of the [http://www.haskell.org/platform/ Haskell platform], so you can find the [http://lambda.haskell.org/platform/doc/current/ API documentation] there.

* [http://darcs.haskell.org/packages/GLUT/ the darcs repo with the sources for the GLUT binding]

+

The [https://github.com/haskell-opengl/GLUT/tree/master/examples examples] directory in the GLUT package contains lots of examples, including translations of the [http://www.opengl.org/documentation/books/#the_opengl_programming_guide_the_official_guide_to_learning_opengl_version Red Book] examples. Both the API documentation and theses examples are best studied with the [http://www.opengl.org/documentation/specs/ original specs] and the original Red Book examples at hand. An index of examples can be found at the OpenGL wiki page [http://www.opengl.org/wiki/Code_Resources Code Resources].

−

In particular, note that the [http://darcs.haskell.org/packages/GLUT/examples/ 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 [http://www.opengl.org/documentation/specs/ original specs] and the original [http://www.opengl.org/documentation/red_book/ red book] examples at hand. An index of the examples from v1.1 of the red book, with screen shots, can be found [http://www.opengl.org/resources/code/samples/redbook/ here]

* [http://www.opengl.org/resources/faq/technical/ OpenGL FAQ and Toubleshooting Guide] Assumes some knowledge of OpenGL. Good for those who have written something but want to avoid common pitfalls.

+

* [http://www.opengl.org/archives/resources/faq/technical/ OpenGL FAQ and Troubleshooting Guide] Assumes some knowledge of OpenGL. Good for those who have written something but want to avoid common pitfalls.

+

** [http://www.opengl.org/archives/resources/faq/technical/gettingstarted.htm#0050 2.100: What is the general form of an OpenGL program?]

+

== Getting Started ==

== Getting Started ==

+

* use the [http://hackage.haskell.org/package/nehe-tuts Haskell port] (Hackage package) of the [http://nehe.gamedev.net/tutorial/lessons_01__05/22004/ NeHe Tutorials]

* assuming you know Haskell, any OpenGL tutorial of your choice should get you going (browsing the [http://www.opengl.org OpenGL] site is also a good idea)

* assuming you know Haskell, any OpenGL tutorial of your choice should get you going (browsing the [http://www.opengl.org OpenGL] site is also a good idea)

−

* use the [http://www.opengl.org/documentation/red_book/ Red Book], and its example code translations, to understand the small differences between OpenGL and HOpenGL

+

* use the [http://www.opengl.org/documentation/books/#the_opengl_programming_guide_the_official_guide_to_learning_opengl_version Red Book], and its example code translations, to understand the small differences between OpenGL and HOpenGL

−

* use the [http://www.opengl.org/documentation/specs/ OpenGL and GLUT specs] to find your way around the [http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL.html HOpenGL Haddock documentation]

+

* use the [http://www.opengl.org/documentation/specs/ OpenGL and GLUT specs] to find your way around the [http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/ HOpenGL Haddock documentation]

* use the [http://www.haskell.org/mailman/listinfo/hopengl HopenGL list] for questions and success stories

* use the [http://www.haskell.org/mailman/listinfo/hopengl HopenGL list] for questions and success stories

* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ALUT ALUT]: A binding for the OpenAL Utility Toolkit

* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ALUT ALUT]: A binding for the OpenAL Utility Toolkit

+

A fork of HOpenGL:

+

* [[OGL]]

+

+

Experiments with raw bindings to GLFW/OpenGL produced with [[HSFFIG]]

+

* [http://code.google.com/p/hs-ogl-misc/ hs-ogl-misc]

== Troubleshooting ==

== Troubleshooting ==

+

=== I can't display text with renderString ===

=== 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.

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

<haskell>

<haskell>

Line 72:

Line 87:

renderString Roman "Test string"

renderString Roman "Test string"

</haskell>

</haskell>

+

+

=== Animations flicker ===

=== 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:

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:

<haskell>

<haskell>

Line 82:

Line 100:

createWindow "My Window"

createWindow "My Window"

</haskell>

</haskell>

−

You will also need to call [http://hackage.haskell.org/packages/archive/GLUT/latest/doc/html/Graphics-UI-GLUT-Window.html#v%3AswapBuffers <haskell>swapBuffers</haskell>] at the end of your draw function.

+

You will also need to call <haskell> swapBuffers </haskell> at the end of your draw function [http://hackage.haskell.org/packages/archive/GLUT/latest/doc/html/Graphics-UI-GLUT-Window.html#v%3AswapBuffers (Read more about swapBuffers)].

+

+

=== 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:

+

<haskell>depthFunc $= Just Less</haskell>

+

+

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

+

<haskell>get (windowParam DepthBits)</haskell>

+

+

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

+

<haskell>openWindow size [DisplayDepthBits 16] Window</haskell>

+

+

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

+

<haskell>clear [ColorBuffer, DepthBuffer]</haskell>

+

+

See also: [http://www.opengl.org/archives/resources/faq/technical/depthbuffer.htm#0010 The OpenGL FAQ: 12.010 How do I make depth buffering work?]

The examples directory in the GLUT package contains lots of examples, including translations of the Red Book examples. Both the API documentation and theses examples are best studied with the original specs and the original Red Book examples at hand. An index of examples can be found at the OpenGL wiki page Code Resources.

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.0010.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: