Skip to content

Instantly share code, notes, and snippets.

@kjell
Created November 5, 2008 01:13
Show Gist options
  • Save kjell/22281 to your computer and use it in GitHub Desktop.
Save kjell/22281 to your computer and use it in GitHub Desktop.
import Graphics.UI.GLUT
import Graphics.Rendering.OpenGL
main = do
(name,_) <- getArgsAndInitialize
createWindow name
displayCallback $= display
mainLoop
display = do
setup
currentColor $= Color4 0.35 0.21 1 1 -- bluish
renderPrimitive Points points
flush
where
gingerbread (x1,y1) = (x1,y1::GLfloat) : gingerbread(1-y1+abs(x1), x1) -- infinite list! (of gingerbread man points)
iterations = take 100000 (gingerbread((-0.1), 0)) -- take the first n from our infinite list. laziness!
points = mapM_ (\(a,b) -> vertex $ Vertex2 a b) iterations -- monads?! turn the pairs we have into vertex commands we can give to renderPrimitive
setup = do
clearColor $= Color4 1 1 1 0.1
clear [ColorBuffer]
scale 0.15 0.15 (0.15::GLfloat)
translate $ Vector3 (-3.1) 0 (0::GLfloat)
rotate 45 $ Vector3 0 0 ((-45)::GLfloat)
-- renders the "gingerbread man" IFS in haskell with some GL libraries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment