Re: Set polygon mode?
C Flynn <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.hopengl |
|---|---|
| Message-ID | <Pine.LNX.4.64.0707231135520.21082@cslin-gps.csunix.comp.leeds.ac.uk> |
On Sun, 22 Jul 2007, Sebastian Sylvan wrote: > On 21/07/07, Hugh Perkins <[email protected]> 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). > I quite like the $= operator. Makes it clear you're playing around with an underlying state variable. In the C binding it's often not clear you're doing this which can lead to unexpected behaviours. Charles,