some help on do and preservingMatrix

Sorry to ask such a basic question here, but I am trying to write my first Haskell OpenGL animation and just encontered with thsese questions: Could someone point me to some help on how does "do" work and how does preservingMatrix? I am trying to write a program starting from the OpenGL tutorial on the wiki, but I never used do's before. My very basic question is that how do I generally repeat a command many times? I understand "do" can do it, but it's not clear to me how to use it and how it works. So if I would like to write the following in one line, how could I write it?: spiral 0.7 spiral 0.8 spiral 0.9 spiral 1.0 I don't understand in which cases I can use "map something [0.7,0.8..1]" and in which cases I need do and how could I map using do.
From the tutorial, I could write this line, which works, but I don't really know what does mapM_ and preservingMatrix do.
mapM_ (\x -> preservingMatrix $ do scale x x (1::GLfloat) rotate (x*(200)) $ Vector3 0 0 (1::GLfloat) spiral ((sin(a/50))^2/2+0.5) ) $ ([0.5,0.6..1::GLfloat]) Zsolt

Hi Zsolt,
I recommend you to try haskell tutorials/books, like LYaHfGG [1] or RWH [2].
Same on OpenGL, RB [3]. preservingMatrix is wrapper of push/popMartix, which
stores opengl transformation matrices in stack (see details in RB).
[1] http://learnyouahaskell.com/chapters
[2] http://book.realworldhaskell.org/read/
[3] http://www.opengl.org/documentation/red_book/
On Thu, Nov 26, 2009 at 8:37 PM, Zsolt Ero
Sorry to ask such a basic question here, but I am trying to write my first Haskell OpenGL animation and just encontered with thsese questions:
Could someone point me to some help on how does "do" work and how does preservingMatrix?
I am trying to write a program starting from the OpenGL tutorial on the wiki, but I never used do's before.
My very basic question is that how do I generally repeat a command many times? I understand "do" can do it, but it's not clear to me how to use it and how it works.
So if I would like to write the following in one line, how could I write it?: spiral 0.7 spiral 0.8 spiral 0.9 spiral 1.0
I don't understand in which cases I can use "map something [0.7,0.8..1]" and in which cases I need do and how could I map using do.
From the tutorial, I could write this line, which works, but I don't really know what does mapM_ and preservingMatrix do.
mapM_ (\x -> preservingMatrix $ do scale x x (1::GLfloat) rotate (x*(200)) $ Vector3 0 0 (1::GLfloat) spiral ((sin(a/50))^2/2+0.5) ) $ ([0.5,0.6..1::GLfloat])
Zsolt _______________________________________________ HOpenGL mailing list HOpenGL@haskell.org http://www.haskell.org/mailman/listinfo/hopengl
-- BR, Stanislav `Cfr` Serebryakov, http://claimid.com/cfr. ,-""-. /--. \ .-.-'`-~ | () ) |<_.-. \--' / `~._ `~' `-..-' `- hjw
participants (2)
-
Stanislav Serebryakov
-
Zsolt Ero