-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedTriangle.hs
More file actions
29 lines (25 loc) · 779 Bytes
/
RedTriangle.hs
File metadata and controls
29 lines (25 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Graphics.UI.GLUT
import System.Exit ( exitWith, ExitCode(ExitSuccess) )
main = do
_ <- getArgsAndInitialize
_ <- createWindow "Red Triangle"
displayCallback $= display
keyboardMouseCallback $= Just keyboard
reshapeCallback $= Just reshape
mainLoop
display :: DisplayCallback
display = do
clear [ColorBuffer]
currentColor $= Color4 1 0 0 1
renderPrimitive Triangles $ do
vertex $ Vertex3 (0 :: GLfloat) 0.5 0
vertex $ Vertex3 (0.5 :: GLfloat) (-0.5) 0
vertex $ Vertex3 (-0.5 :: GLfloat) (-0.5) 0
flush
keyboard :: KeyboardMouseCallback
keyboard (Char '\27') Down _ _ = exitWith ExitSuccess
keyboard _ _ _ _ = return ()
reshape :: ReshapeCallback
reshape size = do
viewport $= (Position 0 0, size)
postRedisplay Nothing