aboutsummaryrefslogtreecommitdiff
path: root/Spear/GLSL/Error.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Spear/GLSL/Error.hs')
-rw-r--r--Spear/GLSL/Error.hs45
1 files changed, 0 insertions, 45 deletions
diff --git a/Spear/GLSL/Error.hs b/Spear/GLSL/Error.hs
deleted file mode 100644
index 7865996..0000000
--- a/Spear/GLSL/Error.hs
+++ /dev/null
@@ -1,45 +0,0 @@
1module Spear.GLSL.Error
2(
3 getGLError
4, printGLError
5, assertGL
6)
7where
8
9
10import Spear.Setup
11
12import Graphics.Rendering.OpenGL.Raw.Core31
13import System.IO (hPutStrLn, stderr)
14
15
16-- | Get the last OpenGL error.
17getGLError :: IO (Maybe String)
18getGLError = fmap translate glGetError
19 where
20 translate err
21 | err == gl_NO_ERROR = Nothing
22 | err == gl_INVALID_ENUM = Just "Invalid enum"
23 | err == gl_INVALID_VALUE = Just "Invalid value"
24 | err == gl_INVALID_OPERATION = Just "Invalid operation"
25 | err == gl_OUT_OF_MEMORY = Just "Out of memory"
26 | otherwise = Just "Unknown error"
27
28
29-- | Print the last OpenGL error.
30printGLError :: IO ()
31printGLError = getGLError >>= \err -> case err of
32 Nothing -> return ()
33 Just str -> hPutStrLn stderr str
34
35
36-- | Run the given 'Setup' action and check for OpenGL errors.
37-- If an OpenGL error is produced, an exception is thrown
38-- containing the given string and the OpenGL error.
39assertGL :: Setup a -> String -> Setup a
40assertGL action err = do
41 result <- action
42 status <- setupIO getGLError
43 case status of
44 Just str -> setupError $ "OpenGL error raised: " ++ err ++ "; " ++ str
45 Nothing -> return result