{-# OPTIONS_HADDOCK hide #-}
module Graphics.Rendering.OpenGL.GL.FramebufferObjects.FramebufferObject (
FramebufferObject(..)
) where
import Control.Monad.IO.Class
import Data.ObjectName
import Foreign.Marshal.Array ( allocaArray, peekArray, withArrayLen )
import Graphics.Rendering.OpenGL.GL.DebugOutput
import Graphics.Rendering.OpenGL.GL.GLboolean
import Graphics.Rendering.OpenGL.GL.QueryUtils
import Graphics.GL
newtype FramebufferObject = FramebufferObject { FramebufferObject -> GLuint
framebufferID :: GLuint }
deriving ( FramebufferObject -> FramebufferObject -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FramebufferObject -> FramebufferObject -> Bool
$c/= :: FramebufferObject -> FramebufferObject -> Bool
== :: FramebufferObject -> FramebufferObject -> Bool
$c== :: FramebufferObject -> FramebufferObject -> Bool
Eq, Eq FramebufferObject
FramebufferObject -> FramebufferObject -> Bool
FramebufferObject -> FramebufferObject -> Ordering
FramebufferObject -> FramebufferObject -> FramebufferObject
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: FramebufferObject -> FramebufferObject -> FramebufferObject
$cmin :: FramebufferObject -> FramebufferObject -> FramebufferObject
max :: FramebufferObject -> FramebufferObject -> FramebufferObject
$cmax :: FramebufferObject -> FramebufferObject -> FramebufferObject
>= :: FramebufferObject -> FramebufferObject -> Bool
$c>= :: FramebufferObject -> FramebufferObject -> Bool
> :: FramebufferObject -> FramebufferObject -> Bool
$c> :: FramebufferObject -> FramebufferObject -> Bool
<= :: FramebufferObject -> FramebufferObject -> Bool
$c<= :: FramebufferObject -> FramebufferObject -> Bool
< :: FramebufferObject -> FramebufferObject -> Bool
$c< :: FramebufferObject -> FramebufferObject -> Bool
compare :: FramebufferObject -> FramebufferObject -> Ordering
$ccompare :: FramebufferObject -> FramebufferObject -> Ordering
Ord, Int -> FramebufferObject -> ShowS
[FramebufferObject] -> ShowS
FramebufferObject -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FramebufferObject] -> ShowS
$cshowList :: [FramebufferObject] -> ShowS
show :: FramebufferObject -> String
$cshow :: FramebufferObject -> String
showsPrec :: Int -> FramebufferObject -> ShowS
$cshowsPrec :: Int -> FramebufferObject -> ShowS
Show )
instance ObjectName FramebufferObject where
isObjectName :: forall (m :: * -> *). MonadIO m => FramebufferObject -> m Bool
isObjectName =
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. (Eq a, Num a) => a -> Bool
unmarshalGLboolean forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). MonadIO m => GLuint -> m GLboolean
glIsFramebuffer forall b c a. (b -> c) -> (a -> b) -> a -> c
. FramebufferObject -> GLuint
framebufferID
deleteObjectNames :: forall (m :: * -> *). MonadIO m => [FramebufferObject] -> m ()
deleteObjectNames [FramebufferObject]
objs =
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
withArrayLen (forall a b. (a -> b) -> [a] -> [b]
map FramebufferObject -> GLuint
framebufferID [FramebufferObject]
objs) forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *). MonadIO m => GLsizei -> Ptr GLuint -> m ()
glDeleteFramebuffers forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral
instance GeneratableObjectName FramebufferObject where
genObjectNames :: forall (m :: * -> *). MonadIO m => Int -> m [FramebufferObject]
genObjectNames Int
n =
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray Int
n forall a b. (a -> b) -> a -> b
$ \Ptr GLuint
buf -> do
forall (m :: * -> *). MonadIO m => GLsizei -> Ptr GLuint -> m ()
glGenFramebuffers (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n) Ptr GLuint
buf
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. (a -> b) -> [a] -> [b]
map GLuint -> FramebufferObject
FramebufferObject) forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray Int
n Ptr GLuint
buf
instance CanBeLabeled FramebufferObject where
objectLabel :: FramebufferObject -> StateVar (Maybe String)
objectLabel = GLuint -> GLuint -> StateVar (Maybe String)
objectNameLabel GLuint
GL_FRAMEBUFFER forall b c a. (b -> c) -> (a -> b) -> a -> c
. FramebufferObject -> GLuint
framebufferID