[HOpenGL] Set polygon mode?

Sebastian Sylvan sebastian.sylvan at gmail.com
Sat Jul 21 19:59:46 EDT 2007


On 21/07/07, Hugh Perkins <hughperkins at gmail.com> wrote:
> Hi, question, how do I do "Gl.glPolygonMode(Gl.GL_BACK, Gl.GL_LINE);" in
> HOpenGl?
>
> Maybe something like "polygonMode $= (Line,Line)" ?
>
> (By the way, what does "$=" do?)
>

>From the docs (
http://www.haskell.org/ghc/docs/latest/html/libraries/index.html ):

polygonMode :: StateVar (PolygonMode, PolygonMode)

So apparently it's a value of type "StateVar ...". Right, so look up
StateVar and we see that it's a data type wich is an instance of
HasGetter and HasSetter. So it appears that it models some sort of
mutable state variable. In this case we want to set the variable, so
HasSetter seems like the right place to look:

class HasSetter s where
       ($=) :: s a -> a -> IO ()

There's no textual description in the doc, but from the type and name
of the class it looks like this takes a statevar, a value, and sets
the state variable to the value. So indeed the following should do
what you want:

polygonMode $= (Line,Line)

And now you should also know what that operator does. It's just a
convenient way of setting OpenGL state variables (and you can also
find e.g. ($~) which modifies a state variable by the function you
pass it).

-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862


More information about the HOpenGL mailing list