[HOpenGL] Projection and Modelview Matrices
Sven Panne
Sven.Panne at aedion.de
Wed Feb 16 03:40:41 EST 2005
Guilherme Lopes wrote:
> I want to do View Frustum Culling using Octrees, and everything is
> working except for one small detail: I cannot find a way to access the
> Projection Matrix, nor the Modelview matrix, which are taken for granted
> in the C/C++ versions of the library.
> Am I missing something? I can of course calculate the clipping
> planes using lookat information and the arguments to the frustum
> function, but cannot believe there isn't a more elegant solution... ;-)
Sorry for replying so slowly, but a HW/SW upgrade kept me busy the last weeks.
If you are using the OpenGL package coming with GHC 6.2(.2), you can access
the current matrix via, well, "currentMatrix": :-)
currentMatrix :: (Matrix m, MatrixComponent c) => StateVar (m c)
i.e.
currentMatrix $= blah
foo <- get currentMatrix
Perhaps you have to set the matrix mode via "matrixMode" before/after doing
that. This is not very elegant, so "currentMatrix" has been deprecated starting
with the OpenGL package shipping with the soon-to-be-released GHC 6.4. The new
"official" and more general way is:
matrix :: (Matrix m, MatrixComponent c) => Maybe MatrixMode -> StateVar (m c)
where "matrix Nothing" is the same as "currentMatrix". In your example you can use:
pm <- get (matrix Projection)
mvm <- get (matrix (Modelview 0))
I really have to continue writing documentation... *sigh*
Hope that helps,
S.
More information about the HOpenGL
mailing list