----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.OGL.Monad -- Copyright : (c) Neal Alexander 2008 -- License : BSD-style (see the file libraries/OpenGL/LICENSE) -- -- Maintainer : relapse.dev@gmx.com -- Stability : experimental -- Portability : ghc -- -- GL Contexts: -- -- - 'MonadGL' a command that can be used in any OpenGL context. -- -- - 'GL' a basic command that cannot be used between begin\/end. -- -- - 'PrimitiveGL' a primitive command sent during begin\/end context. -- module Graphics.Rendering.OGL.Monad (liftIO, liftGL, runGL, runGLA, GL(..), runPrimitive, PrimitiveGL(..), MonadGL) where import Control.Monad import Control.Applicative import Control.Monad.Trans import Control.Arrow class MonadIO m => MonadGL m instance MonadGL GL instance MonadGL PrimitiveGL newtype GL a = GL (IO a) deriving (Functor, Monad, MonadIO) newtype PrimitiveGL a = PrimitiveGL (IO a) deriving (Functor, Monad, MonadIO) runGL :: GL a -> IO a runGL (GL x) = x -- | arrow version of runGL runGLA :: Kleisli GL a a -> Kleisli IO a a runGLA a = Kleisli $ runGL . runKleisli a -- | Same as: liftIO . runGL liftGL :: MonadIO m => GL a -> m a liftGL = liftIO . runGL -- | This is used internally and shouldnt be needed by the user. runPrimitive :: PrimitiveGL a -> IO a runPrimitive (PrimitiveGL x) = x