[Haskell-beginners] Haskell and OpenGL
Stephen Blackheath [to Haskell-Beginners]
mutilating.cauliflowers.stephen at blacksapphire.com
Thu Feb 25 17:58:26 EST 2010
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.
import Graphics.Rendering.OpenGL as GL
display :: IO ()
display = do
clearColor $= bgColour
clear [ColorBuffer, DepthBuffer]
... draw stuff here ...
animate :: IO ()
animate = do
addTimerCallback 16 $ animate
main :: IO ()
main = do
initialDisplayMode $= [DoubleBuffered, WithDepthBuffer]
-- 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
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.
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners