module Graphics.Rendering.OpenGL.GL.Texturing.TextureObject (
TextureObject(..)
) where
import Foreign.Marshal.Array
import Graphics.Rendering.OpenGL.GL.GLboolean
import Graphics.Rendering.OpenGL.GL.ObjectName
import Graphics.Rendering.OpenGL.Raw
newtype TextureObject = TextureObject { textureID :: GLuint }
deriving ( Eq, Ord, Show )
instance ObjectName TextureObject where
isObjectName = fmap unmarshalGLboolean . glIsTexture . textureID
deleteObjectNames textureObjects =
withArrayLen (map textureID textureObjects) $
glDeleteTextures . fromIntegral
instance GeneratableObjectName TextureObject where
genObjectNames n =
allocaArray n $ \buf -> do
glGenTextures (fromIntegral n) buf
fmap (map TextureObject) $ peekArray n buf