[Haskell-beginners] Haskell and OpenGL
Stephen Blackheath [to Haskell-Beginners]
mutilating.cauliflowers.stephen at blacksapphire.com
Thu Feb 25 17:58:26 EST 2010
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 at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list