[HOpenGL] (not?) using preservingMatrix
Sebastian Sylvan
sebastian.sylvan at gmail.com
Fri Jan 5 14:22:18 EST 2007
On 1/5/07, Sebastian Sylvan <sebastian.sylvan at gmail.com> wrote:
> On 1/5/07, jamin1001 <jamin1001 at yahoo.com> wrote:
> >
> > Right, I buy that. But I don't see how the C line
> >
> > glGetFloatv (GL_MODELVIEW_MATRIX, your_matrix_result) ;
> >
> > can be done, since it writes a result into your_matrix_result, so I would
> > need something like:
> >
> > preservingMatrix $ do
> > loadIdentity
> > -- do whatever you want with your your matrix
> > rs <- get ((matrix $ Just $ Modelview 0)::StateVar(GLmatrix GLdouble))
>
> This does indeed compile for me. GHC 6.6.
>
Though I would've probably avoidd all those ugly type signatures and
either put one on the action which does this, or (probably) just not
specify the type at all since whatever you do with rs will likely
narrow the type down to GLmatrix GLdouble anyway. Or if it still
doesn't work you could write:
s <- get $ matrix $ Just $ Modelview 0 :: IO (GLmatrix GLdouble)
And get rid of some of the clutter. The reason you need a type is due
to the monomorphism restriction, which you can get rid of using
-fno-monomorphis-restriction.
Also you don't need to use "matrix", you can use "currentMatrix"
(analogous to your C code), which will retrieve whatever matrix is set
using the matrixMode state variable.
--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
More information about the HOpenGL
mailing list