{-

HOpenGL Tutorial - Andre W B Furtado - 2001
www.cin.ufpe.br/~haskell/hopengl/
awbf@cin.ufpe.br

** Drawing Primitives and Modifying Colors **

-}

import GLUT
import GL

myInit :: IO () 
myInit = do
	clearColor (Color4 0.0 0.0 0.0 0.0)
	matrixMode Projection
	loadIdentity
	ortho 0.0 1.0 0.0 1.0 (-1.0) 1.0

ex2 :: IO ()
ex2 = do
	color (Color3 0.0 1.0 0.0 :: Color3 GLfloat)
	beginEnd LineLoop $ mapM_ vertex [
		Vertex3 0.20 0.10 0.0,
		Vertex3 0.50 0.90 0.0,
		Vertex3 0.80 0.10 0.0,
		Vertex3 0.10 0.60 0.0,
		Vertex3 0.90 0.60 (0.0 :: GLfloat)]
			
display :: DisplayAction
display = do 
	clear [ColorBufferBit]
	ex2
	flush

main :: IO ()
main = do
	GLUT.init Nothing
	createWindow "Primitivas - Exemplo 2" (return ()) [ Single, GLUT.Rgb ]
			(Just (WindowPosition 100 100))
			(Just (WindowSize     250 250))
	myInit
	displayFunc (display)
	mainLoop