1
1
{-
2
2
Triangles.hs (adapted from triangles.cpp which is (c) The Red Book Authors.)
3
- Copyright (c) Sven Panne 2013 <[email protected] >
3
+ Copyright (c) Sven Panne 2014 <[email protected] >
4
4
This file is part of HOpenGL and distributed under a BSD-style license
5
5
See the file libraries/GLUT/LICENSE
6
6
@@ -13,17 +13,8 @@ import Foreign.Ptr
13
13
import Foreign.Storable
14
14
import Graphics.UI.GLUT
15
15
import Prelude hiding ( init )
16
- import System.IO
17
16
import LoadShaders
18
17
19
- -- TODO: Just for debugging, remove me later.
20
- checkError :: String -> IO ()
21
- checkError functionName = get errors >>= mapM_ reportError
22
- where reportError e =
23
- hPutStrLn stderr (showError e ++ " detected in " ++ functionName)
24
- showError (Error category message) =
25
- " GL error " ++ show category ++ " (" ++ message ++ " )"
26
-
27
18
bufferOffset :: Integral a => a -> Ptr b
28
19
bufferOffset = plusPtr nullPtr . fromIntegral
29
20
@@ -60,7 +51,6 @@ init = do
60
51
(ToFloat , VertexArrayDescriptor 2 Float 0 (bufferOffset firstIndex))
61
52
vertexAttribArray vPosition $= Enabled
62
53
63
- checkError " init"
64
54
return $ Descriptor triangles firstIndex (fromIntegral numVertices)
65
55
66
56
display :: Descriptor -> DisplayCallback
@@ -69,18 +59,13 @@ display (Descriptor triangles firstIndex numVertices) = do
69
59
bindVertexArrayObject $= Just triangles
70
60
drawArrays Triangles firstIndex numVertices
71
61
flush
72
- checkError " display"
73
62
74
63
main :: IO ()
75
64
main = do
76
65
(progName, _args) <- getArgsAndInitialize
77
66
initialDisplayMode $= [ RGBAMode ]
78
67
initialWindowSize $= Size 512 512
79
68
initialContextVersion $= (4 , 3 )
80
-
81
- -- TODO: Just for debugging, remove me later.
82
- initialContextFlags $= [ DebugContext ]
83
-
84
69
initialContextProfile $= [ CoreProfile ]
85
70
_ <- createWindow progName
86
71
descriptor <- init
0 commit comments