{-# OPTIONS_HADDOCK hide #-}
module Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit (
TextureUnit(..), marshalTextureUnit, unmarshalTextureUnit
) where
import Foreign.Ptr
import Foreign.Storable
import Graphics.GL
newtype TextureUnit = TextureUnit GLuint
deriving ( TextureUnit -> TextureUnit -> Bool
(TextureUnit -> TextureUnit -> Bool)
-> (TextureUnit -> TextureUnit -> Bool) -> Eq TextureUnit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextureUnit -> TextureUnit -> Bool
$c/= :: TextureUnit -> TextureUnit -> Bool
== :: TextureUnit -> TextureUnit -> Bool
$c== :: TextureUnit -> TextureUnit -> Bool
Eq, Eq TextureUnit
Eq TextureUnit =>
(TextureUnit -> TextureUnit -> Ordering)
-> (TextureUnit -> TextureUnit -> Bool)
-> (TextureUnit -> TextureUnit -> Bool)
-> (TextureUnit -> TextureUnit -> Bool)
-> (TextureUnit -> TextureUnit -> Bool)
-> (TextureUnit -> TextureUnit -> TextureUnit)
-> (TextureUnit -> TextureUnit -> TextureUnit)
-> Ord TextureUnit
TextureUnit -> TextureUnit -> Bool
TextureUnit -> TextureUnit -> Ordering
TextureUnit -> TextureUnit -> TextureUnit
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 :: TextureUnit -> TextureUnit -> TextureUnit
$cmin :: TextureUnit -> TextureUnit -> TextureUnit
max :: TextureUnit -> TextureUnit -> TextureUnit
$cmax :: TextureUnit -> TextureUnit -> TextureUnit
>= :: TextureUnit -> TextureUnit -> Bool
$c>= :: TextureUnit -> TextureUnit -> Bool
> :: TextureUnit -> TextureUnit -> Bool
$c> :: TextureUnit -> TextureUnit -> Bool
<= :: TextureUnit -> TextureUnit -> Bool
$c<= :: TextureUnit -> TextureUnit -> Bool
< :: TextureUnit -> TextureUnit -> Bool
$c< :: TextureUnit -> TextureUnit -> Bool
compare :: TextureUnit -> TextureUnit -> Ordering
$ccompare :: TextureUnit -> TextureUnit -> Ordering
$cp1Ord :: Eq TextureUnit
Ord, Int -> TextureUnit -> ShowS
[TextureUnit] -> ShowS
TextureUnit -> String
(Int -> TextureUnit -> ShowS)
-> (TextureUnit -> String)
-> ([TextureUnit] -> ShowS)
-> Show TextureUnit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextureUnit] -> ShowS
$cshowList :: [TextureUnit] -> ShowS
show :: TextureUnit -> String
$cshow :: TextureUnit -> String
showsPrec :: Int -> TextureUnit -> ShowS
$cshowsPrec :: Int -> TextureUnit -> ShowS
Show )
instance Storable TextureUnit where
sizeOf :: TextureUnit -> Int
sizeOf _ = GLuint -> Int
forall a. Storable a => a -> Int
sizeOf (GLuint
forall a. HasCallStack => a
undefined :: GLuint)
alignment :: TextureUnit -> Int
alignment _ = GLuint -> Int
forall a. Storable a => a -> Int
alignment (GLuint
forall a. HasCallStack => a
undefined :: GLuint)
peek :: Ptr TextureUnit -> IO TextureUnit
peek pt :: Ptr TextureUnit
pt = Ptr GLuint -> IO GLuint
forall a. Storable a => Ptr a -> IO a
peek (Ptr TextureUnit -> Ptr GLuint
forall a b. Ptr a -> Ptr b
castPtr Ptr TextureUnit
pt) IO GLuint -> (GLuint -> IO TextureUnit) -> IO TextureUnit
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= TextureUnit -> IO TextureUnit
forall (m :: * -> *) a. Monad m => a -> m a
return (TextureUnit -> IO TextureUnit)
-> (GLuint -> TextureUnit) -> GLuint -> IO TextureUnit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLuint -> TextureUnit
TextureUnit
poke :: Ptr TextureUnit -> TextureUnit -> IO ()
poke pt :: Ptr TextureUnit
pt (TextureUnit tu :: GLuint
tu) = Ptr GLuint -> GLuint -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TextureUnit -> Ptr GLuint
forall a b. Ptr a -> Ptr b
castPtr Ptr TextureUnit
pt) GLuint
tu
peekByteOff :: Ptr b -> Int -> IO TextureUnit
peekByteOff pt :: Ptr b
pt off :: Int
off = Ptr b -> Int -> IO GLuint
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr b
pt Int
off IO GLuint -> (GLuint -> IO TextureUnit) -> IO TextureUnit
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= TextureUnit -> IO TextureUnit
forall (m :: * -> *) a. Monad m => a -> m a
return (TextureUnit -> IO TextureUnit)
-> (GLuint -> TextureUnit) -> GLuint -> IO TextureUnit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLuint -> TextureUnit
TextureUnit
pokeByteOff :: Ptr b -> Int -> TextureUnit -> IO ()
pokeByteOff pt :: Ptr b
pt off :: Int
off (TextureUnit tu :: GLuint
tu)
= Ptr b -> Int -> GLuint -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr b
pt Int
off GLuint
tu
marshalTextureUnit :: TextureUnit -> GLenum
marshalTextureUnit :: TextureUnit -> GLuint
marshalTextureUnit (TextureUnit x :: GLuint
x) = GLuint
GL_TEXTURE0 GLuint -> GLuint -> GLuint
forall a. Num a => a -> a -> a
+ GLuint -> GLuint
forall a b. (Integral a, Num b) => a -> b
fromIntegral GLuint
x
unmarshalTextureUnit :: GLenum -> TextureUnit
unmarshalTextureUnit :: GLuint -> TextureUnit
unmarshalTextureUnit x :: GLuint
x = GLuint -> TextureUnit
TextureUnit (GLuint -> GLuint
forall a b. (Integral a, Num b) => a -> b
fromIntegral (GLuint
x GLuint -> GLuint -> GLuint
forall a. Num a => a -> a -> a
- GLuint
GL_TEXTURE0))