{-# 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 ( Eq, Ord, Show )
instance Storable TextureUnit where
sizeOf _ = sizeOf (undefined :: GLuint)
alignment _ = alignment (undefined :: GLuint)
peek pt = peek (castPtr pt) >>= return . TextureUnit
poke pt (TextureUnit tu) = poke (castPtr pt) tu
peekByteOff pt off = peekByteOff pt off >>= return . TextureUnit
pokeByteOff pt off (TextureUnit tu)
= pokeByteOff pt off tu
marshalTextureUnit :: TextureUnit -> GLenum
marshalTextureUnit (TextureUnit x) = GL_TEXTURE0 + fromIntegral x
unmarshalTextureUnit :: GLenum -> TextureUnit
unmarshalTextureUnit x = TextureUnit (fromIntegral (x - GL_TEXTURE0))