-
Notifications
You must be signed in to change notification settings - Fork 2
/
Initialize.hs
44 lines (34 loc) · 1.15 KB
/
Initialize.hs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Haskeroids.Initialize where
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
import Haskeroids.Callbacks
-- | Set up the main application window
initializeWindow = do
_ <- getArgsAndInitialize
initialWindowSize $= Size 800 600
initialDisplayMode $= [DoubleBuffered]
createWindow "Haskeroids"
-- | Set up the initial OpenGL parameters
initializeOpenGL = do
-- Disable depth checking as we won't be needing it in 2D
depthMask $= Disabled
-- Nicer line drawing
lineSmooth $= Enabled
blend $= Enabled
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
lineWidth $= 2.0
-- Set up viewport
viewport $= (Position 0 0, Size 800 600)
-- Set up an orthogonal projection for 2D rendering
matrixMode $= Projection
loadIdentity
ortho 0 800 600 0 (-1) 1
matrixMode $= Modelview 0
loadIdentity
-- Set background color to dark bluish black
clearColor $= Color4 0.0 0.0 0.1 1.0
-- | Set up GLUT callbacks
initializeCallbacks = do
refs <- initCallbackRefs
keyboardMouseCallback $= Just (handleKeyboard refs)
displayCallback $= renderViewport refs