[HOpenGL] (not?) using preservingMatrix
Sven Panne
sven.panne at aedion.de
Sat Jan 6 11:20:10 EST 2007
Am Freitag, 5. Januar 2007 22:19 schrieb jamin1001:
> Thank you very much. I appreciate the detailed response and extra tips!
Thanks to Sebastian, too. Just a few remarks from my side:
* preservingMatrix actually does a little bit more: It uses the current
matrix mode in effect at the time it was called when popping the matrix, and
does this in an exception-safe way. There is a variant for performance freaks
and/or people who can guarantee that an exception will never be thrown by the
action passed (unsafePreservingMatrix). In the same spirit, there is an
unsafe variant of renderPrimitive, too.
* "currentMatrix" is equivalent to "matrix Nothing", using whichever matrix
mode is currently set. The example given states an explicit matrix to be
accessed.
* Sometimes explicit type signatures are needed when the OpenGL package is
used, although this rarely happens for non-toy programs. This is a
consequence of a design decision to be quite flexible regarding the
represenation of some data structures (matrices, in our example). Although
there is already a ready-to-use GLmatrix type, one could use custom data
structures for matrices, as long as they are an instance of the class Matrix
(define withNewMatrix or newMatrix, plus withMatrix or getMatrixComponents).
Similar examples are the Map1/Map2/PolygonStipple classes.
* A hopefully good source of examples is the "examples" subdirectory of the
GLUT package (http://darcs.haskell.org/packages/GLUT/examples/), which I
intend to extend constantly. The style follows the books in question very
closely, so it should be easy to see how the OpenGL package can be used. An
example which retrieves a calculated matrix is in
http://darcs.haskell.org/packages/GLUT/examples/RedBook/ShadowMap.hs
(see generateTextureMatrix).
Cheers,
S.
More information about the HOpenGL
mailing list