These are the examples I wish I had when I started learning OpenGL. There are more examples in the wild of the deprecated pre-3.0 API than of modern OpenGL, and of course nearly all are in C(++). The usual assortment of GLUT and other windowing frameworks doesn't help.
These examples (will eventually) cover several different choices of Haskell wrapper over OpenGL:
- modern buffers & VAOs using the OpenGL package
- GLUtil wrappers to reduce boilerplate & imperative style
- vinyl-gl (extensible Haskell records, GHC type hackery) to remove more boilerplate
All examples use GLFW-b for windowing. There are a few helper
src/Util which are used in all the examples.
I've otherwise tried to avoid such functions, to make it easier to
pick any example and see what is going on. Most functions I'd want
are provided by
GLUtil anyway, and the point of the "-modern"
examples is to show the use of the OpenGL bindings without those
To some extent it's also possible to mix and match these approaches.
One can use custom shaders with the
gl_Modelview matrix, or
drawArrays with the fixed-function pipeline.
If you are using these examples and find something missing or difficult to understand, please open an issue. Pull requests are also welcome.
The example programs:
wikibookports a few examples from the excellent OpenGL Wikibook
glfw(2D rotating triangle, based on the example that ships with GLFW)
cabal install in this directory will build all of the
tutorial examples. Take a look at
the .cabal file to see how the
executables are named.