Debian Codegraph @

src/Graphics/UI/GLUT/Debugging.hs

raw
1 --------------------------------------------------------------------------------
2 -- |
3 -- Module : Graphics.UI.GLUT.Debugging
4 -- Copyright : (c) Sven Panne 2002-2018
5 -- License : BSD3
6 --
7 -- Maintainer : Sven Panne <[email protected]>
8 -- Stability : stable
9 -- Portability : portable
10 --
11 -- This module contains a simple utility routine to report any pending GL
12 -- errors.
13 --
14 --------------------------------------------------------------------------------
15
16 module Graphics.UI.GLUT.Debugging (
17 reportErrors
18 ) where
19
20 import Control.Monad.IO.Class ( MonadIO(..) )
21 import Data.StateVar ( get )
22 import Graphics.Rendering.OpenGL ( Error(..), errors )
23 import System.Environment ( getProgName )
24 import System.IO ( hPutStrLn, stderr )
25
26 --------------------------------------------------------------------------------
27
28 -- | Report any pending GL errors to stderr (which is typically the console).
29 -- If there are no pending errors, this routine does nothing. Note that the
30 -- error flags are reset after this action, i.e. there are no pending errors
31 -- left afterwards.
32
33 reportErrors :: MonadIO m => m ()
34 reportErrors = get errors >>= mapM_ reportError
35
36 reportError :: MonadIO m => Error -> m ()
37 reportError (Error _ msg) = liftIO $ do
38 pn <- getProgName
39 hPutStrLn stderr ("GLUT: Warning in " ++ pn ++ ": GL error: " ++ msg)