
For anyone comfortable with OpenGl in Haskell, what is the equivalent for glutTimerFunc? Is it addTimerCallback? If so, how does it work--I've tried it and I can't seem to get it to work... It's really odd that there are straightforward implementations of callbacks for display, window resize, keyboard/mouse, etc., but not for something as common as a timer callback. Thanks, Tyler

Tyler, Hopefully this will help. I chopped some bits out of a working program that you should be able to use as a skeleton. If you have any other OpenGL package questions, ask away. I've been using it a lot. Steve import Graphics.Rendering.OpenGL as GL import Graphics.UI.GLUT display :: IO () display = do clearColor $= bgColour clear [ColorBuffer, DepthBuffer] loadIdentity ... draw stuff here ... swapBuffers animate :: IO () animate = do postRedisplay Nothing addTimerCallback 16 $ animate main :: IO () main = do initialDisplayMode $= [DoubleBuffered, WithDepthBuffer] createWindow "Hello" -- OpenGL initialization - must be after 'createWindow' windowSize $= Size 700 700 depthFunc $= Just Less shadeModel $= Smooth lighting $= Enabled ambient (Light 0) $= Color4 0.1 0.1 0.1 (tof 1) diffuse (Light 0) $= Color4 0.9 0.9 0.9 (tof 1) light (Light 0) $= Enabled ... displayCallback $= display addTimerCallback 16 $ animate -- refresh every 16 milliseconds mainLoop Tyler Hayes wrote:
For anyone comfortable with OpenGl in Haskell, what is the equivalent for glutTimerFunc? Is it addTimerCallback? If so, how does it work--I've tried it and I can't seem to get it to work...
It's really odd that there are straightforward implementations of callbacks for display, window resize, keyboard/mouse, etc., but not for something as common as a timer callback.
Thanks, Tyler
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Thu, 2010-02-25 at 12:59 -0800, Tyler Hayes wrote:
For anyone comfortable with OpenGl in Haskell, what is the equivalent for glutTimerFunc? Is it addTimerCallback? If so, how does it work--I've tried it and I can't seem to get it to work...
According to source it calls glutTimerFunc with timeout, the callback and 0. Such code seems to works for me:
import Graphics.UI.GLUT
main = do getArgsAndInitialize _ <- createWindow "Test" addTimerCallback 1000 (putStrLn "Callback") mainLoop
What do you mean 'to get it to work'? Regards
participants (3)
-
Maciej Piechotka
-
Stephen Blackheath [to Haskell-Beginners]
-
Tyler Hayes