--------------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Rendering.OpenGL.GL.Texturing.Queries
-- Copyright   :  (c) Sven Panne 2002-2019
-- License     :  BSD3
--
-- Maintainer  :  Sven Panne <svenpanne@gmail.com>
-- Stability   :  stable
-- Portability :  portable
--
-- This module offers various texture queries.
--
--------------------------------------------------------------------------------

module Graphics.Rendering.OpenGL.GL.Texturing.Queries (
   TextureQuery, textureInternalFormat, textureSize1D, textureSize2D,
   textureSize3D, textureBorder, textureRGBASizes, textureSharedSize,
   textureIntensitySize, textureLuminanceSize, textureIndexSize,
   textureDepthBits, textureCompressedImageSize, textureProxyOK,
   DataRepresentation(..), textureRGBATypes, textureIntensityType,
   textureLuminanceType, textureDepthType
) where

import Control.Monad
import Data.StateVar
import Foreign.Marshal.Utils
import Graphics.Rendering.OpenGL.GL.DataType
import Graphics.Rendering.OpenGL.GL.GLboolean
import Graphics.Rendering.OpenGL.GL.PeekPoke
import Graphics.Rendering.OpenGL.GL.PixelRectangles
import Graphics.Rendering.OpenGL.GL.Texturing.PixelInternalFormat
import Graphics.Rendering.OpenGL.GL.Texturing.Specification
import Graphics.Rendering.OpenGL.GL.Texturing.TextureTarget
import Graphics.Rendering.OpenGL.GL.VertexSpec
import Graphics.GL

--------------------------------------------------------------------------------

data TexLevelParameter =
     TextureInternalFormat
   | TextureWidth
   | TextureHeight
   | TextureDepth
   | TextureBorder
   | TextureRedSize
   | TextureGreenSize
   | TextureBlueSize
   | TextureAlphaSize
   | TextureIntensitySize
   | TextureLuminanceSize
   | TextureIndexSize
   | DepthBits
   | TextureCompressedImageSize
   | TextureCompressed
   | TextureSharedSize
   | TextureRedType
   | TextureGreenType
   | TextureBlueType
   | TextureAlphaType
   | TextureLuminanceType
   | TextureIntensityType
   | TextureDepthType

marshalTexLevelParameter :: TexLevelParameter -> GLenum
marshalTexLevelParameter :: TexLevelParameter -> GLenum
marshalTexLevelParameter TexLevelParameter
x = case TexLevelParameter
x of
   TexLevelParameter
TextureInternalFormat -> GLenum
GL_TEXTURE_INTERNAL_FORMAT
   TexLevelParameter
TextureWidth -> GLenum
GL_TEXTURE_WIDTH
   TexLevelParameter
TextureHeight -> GLenum
GL_TEXTURE_HEIGHT
   TexLevelParameter
TextureDepth -> GLenum
GL_TEXTURE_DEPTH
   TexLevelParameter
TextureBorder -> GLenum
GL_TEXTURE_BORDER
   TexLevelParameter
TextureRedSize -> GLenum
GL_TEXTURE_RED_SIZE
   TexLevelParameter
TextureGreenSize -> GLenum
GL_TEXTURE_GREEN_SIZE
   TexLevelParameter
TextureBlueSize -> GLenum
GL_TEXTURE_BLUE_SIZE
   TexLevelParameter
TextureAlphaSize -> GLenum
GL_TEXTURE_ALPHA_SIZE
   TexLevelParameter
TextureIntensitySize -> GLenum
GL_TEXTURE_INTENSITY_SIZE
   TexLevelParameter
TextureLuminanceSize -> GLenum
GL_TEXTURE_LUMINANCE_SIZE
   TexLevelParameter
TextureIndexSize -> GLenum
GL_TEXTURE_INDEX_SIZE_EXT
   TexLevelParameter
DepthBits -> GLenum
GL_DEPTH_BITS
   TexLevelParameter
TextureCompressedImageSize -> GLenum
GL_TEXTURE_COMPRESSED_IMAGE_SIZE
   TexLevelParameter
TextureCompressed -> GLenum
GL_TEXTURE_COMPRESSED
   TexLevelParameter
TextureSharedSize -> GLenum
GL_TEXTURE_SHARED_SIZE
   TexLevelParameter
TextureRedType -> GLenum
GL_TEXTURE_RED_TYPE_ARB
   TexLevelParameter
TextureGreenType -> GLenum
GL_TEXTURE_GREEN_TYPE_ARB
   TexLevelParameter
TextureBlueType -> GLenum
GL_TEXTURE_BLUE_TYPE_ARB
   TexLevelParameter
TextureAlphaType -> GLenum
GL_TEXTURE_ALPHA_TYPE_ARB
   TexLevelParameter
TextureLuminanceType -> GLenum
GL_TEXTURE_LUMINANCE_TYPE_ARB
   TexLevelParameter
TextureIntensityType -> GLenum
GL_TEXTURE_INTENSITY_TYPE_ARB
   TexLevelParameter
TextureDepthType -> GLenum
GL_TEXTURE_DEPTH_TYPE_ARB

--------------------------------------------------------------------------------

type TextureQuery t a = t -> Level -> GettableStateVar a

textureInternalFormat :: QueryableTextureTarget t => TextureQuery t PixelInternalFormat
textureInternalFormat :: forall t.
QueryableTextureTarget t =>
TextureQuery t PixelInternalFormat
textureInternalFormat t
t GLint
level =
   IO PixelInternalFormat -> IO PixelInternalFormat
forall a. IO a -> IO a
makeGettableStateVar (IO PixelInternalFormat -> IO PixelInternalFormat)
-> IO PixelInternalFormat -> IO PixelInternalFormat
forall a b. (a -> b) -> a -> b
$
      (GLint -> PixelInternalFormat)
-> t -> GLint -> TexLevelParameter -> IO PixelInternalFormat
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> PixelInternalFormat
unmarshalPixelInternalFormat t
t GLint
level TexLevelParameter
TextureInternalFormat

textureSize1D :: TextureQuery TextureTarget1D TextureSize1D
textureSize1D :: TextureQuery TextureTarget1D TextureSize1D
textureSize1D TextureTarget1D
t GLint
level =
   IO TextureSize1D -> IO TextureSize1D
forall a. IO a -> IO a
makeGettableStateVar (IO TextureSize1D -> IO TextureSize1D)
-> IO TextureSize1D -> IO TextureSize1D
forall a b. (a -> b) -> a -> b
$
      (GLint -> TextureSize1D) -> IO GLint -> IO TextureSize1D
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM GLint -> TextureSize1D
TextureSize1D
            ((GLint -> GLint)
-> TextureTarget1D -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral TextureTarget1D
t GLint
level TexLevelParameter
TextureWidth)

textureSize2D :: TextureQuery TextureTarget2D TextureSize2D
textureSize2D :: TextureQuery TextureTarget2D TextureSize2D
textureSize2D TextureTarget2D
t GLint
level =
   IO TextureSize2D -> IO TextureSize2D
forall a. IO a -> IO a
makeGettableStateVar (IO TextureSize2D -> IO TextureSize2D)
-> IO TextureSize2D -> IO TextureSize2D
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint -> TextureSize2D)
-> IO GLint -> IO GLint -> IO TextureSize2D
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 GLint -> GLint -> TextureSize2D
TextureSize2D
             ((GLint -> GLint)
-> TextureTarget2D -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral TextureTarget2D
t GLint
level TexLevelParameter
TextureWidth )
             ((GLint -> GLint)
-> TextureTarget2D -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral TextureTarget2D
t GLint
level TexLevelParameter
TextureHeight)

textureSize3D :: TextureQuery TextureTarget3D TextureSize3D
textureSize3D :: TextureQuery TextureTarget3D TextureSize3D
textureSize3D TextureTarget3D
t GLint
level =
   IO TextureSize3D -> IO TextureSize3D
forall a. IO a -> IO a
makeGettableStateVar (IO TextureSize3D -> IO TextureSize3D)
-> IO TextureSize3D -> IO TextureSize3D
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint -> GLint -> TextureSize3D)
-> IO GLint -> IO GLint -> IO GLint -> IO TextureSize3D
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 GLint -> GLint -> GLint -> TextureSize3D
TextureSize3D
             ((GLint -> GLint)
-> TextureTarget3D -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral TextureTarget3D
t GLint
level TexLevelParameter
TextureWidth )
             ((GLint -> GLint)
-> TextureTarget3D -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral TextureTarget3D
t GLint
level TexLevelParameter
TextureHeight)
             ((GLint -> GLint)
-> TextureTarget3D -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral TextureTarget3D
t GLint
level TexLevelParameter
TextureDepth )

textureBorder :: QueryableTextureTarget t => TextureQuery t Border
textureBorder :: forall t. QueryableTextureTarget t => TextureQuery t GLint
textureBorder t
t GLint
level =
   IO GLint -> IO GLint
forall a. IO a -> IO a
makeGettableStateVar (IO GLint -> IO GLint) -> IO GLint -> IO GLint
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureBorder

textureRGBASizes :: QueryableTextureTarget t =>  TextureQuery t (Color4 GLsizei)
textureRGBASizes :: forall t. QueryableTextureTarget t => TextureQuery t (Color4 GLint)
textureRGBASizes t
t GLint
level =
   IO (Color4 GLint) -> IO (Color4 GLint)
forall a. IO a -> IO a
makeGettableStateVar (IO (Color4 GLint) -> IO (Color4 GLint))
-> IO (Color4 GLint) -> IO (Color4 GLint)
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint -> GLint -> GLint -> Color4 GLint)
-> IO GLint
-> IO GLint
-> IO GLint
-> IO GLint
-> IO (Color4 GLint)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 GLint -> GLint -> GLint -> GLint -> Color4 GLint
forall a. a -> a -> a -> a -> Color4 a
Color4
             ((GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureRedSize  )
             ((GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureGreenSize)
             ((GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureBlueSize )
             ((GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureAlphaSize)

textureSharedSize :: QueryableTextureTarget t =>  TextureQuery t GLsizei
textureSharedSize :: forall t. QueryableTextureTarget t => TextureQuery t GLint
textureSharedSize t
t GLint
level =
   IO GLint -> IO GLint
forall a. IO a -> IO a
makeGettableStateVar (IO GLint -> IO GLint) -> IO GLint -> IO GLint
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureSharedSize

textureIntensitySize :: QueryableTextureTarget t => TextureQuery t GLsizei
textureIntensitySize :: forall t. QueryableTextureTarget t => TextureQuery t GLint
textureIntensitySize t
t GLint
level =
   IO GLint -> IO GLint
forall a. IO a -> IO a
makeGettableStateVar (IO GLint -> IO GLint) -> IO GLint -> IO GLint
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureIntensitySize

textureLuminanceSize :: QueryableTextureTarget t =>  TextureQuery t GLsizei
textureLuminanceSize :: forall t. QueryableTextureTarget t => TextureQuery t GLint
textureLuminanceSize t
t GLint
level =
   IO GLint -> IO GLint
forall a. IO a -> IO a
makeGettableStateVar (IO GLint -> IO GLint) -> IO GLint -> IO GLint
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureLuminanceSize

textureIndexSize :: QueryableTextureTarget t => TextureQuery t GLsizei
textureIndexSize :: forall t. QueryableTextureTarget t => TextureQuery t GLint
textureIndexSize t
t GLint
level =
   IO GLint -> IO GLint
forall a. IO a -> IO a
makeGettableStateVar (IO GLint -> IO GLint) -> IO GLint -> IO GLint
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
TextureIndexSize

textureDepthBits :: QueryableTextureTarget t => TextureQuery t GLsizei
textureDepthBits :: forall t. QueryableTextureTarget t => TextureQuery t GLint
textureDepthBits t
t GLint
level =
   IO GLint -> IO GLint
forall a. IO a -> IO a
makeGettableStateVar (IO GLint -> IO GLint) -> IO GLint -> IO GLint
forall a b. (a -> b) -> a -> b
$
      (GLint -> GLint) -> t -> GLint -> TexLevelParameter -> IO GLint
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral t
t GLint
level TexLevelParameter
DepthBits

textureCompressedImageSize :: QueryableTextureTarget t => TextureQuery t (Maybe GLsizei)
textureCompressedImageSize :: forall t. QueryableTextureTarget t => TextureQuery t (Maybe GLint)
textureCompressedImageSize t
t GLint
level =
   IO (Maybe GLint) -> IO (Maybe GLint)
forall a. IO a -> IO a
makeGettableStateVar (IO (Maybe GLint) -> IO (Maybe GLint))
-> IO (Maybe GLint) -> IO (Maybe GLint)
forall a b. (a -> b) -> a -> b
$ do
      Bool
isCompressed <- (GLint -> Bool) -> t -> GLint -> TexLevelParameter -> IO Bool
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> Bool
forall a. (Eq a, Num a) => a -> Bool
unmarshalGLboolean t
t GLint
level TexLevelParameter
TextureCompressed
      if Bool
isCompressed
         then (GLint -> Maybe GLint)
-> t -> GLint -> TexLevelParameter -> IO (Maybe GLint)
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy (GLint -> Maybe GLint
forall a. a -> Maybe a
Just (GLint -> Maybe GLint) -> (GLint -> GLint) -> GLint -> Maybe GLint
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLint -> GLint
forall a b. (Integral a, Num b) => a -> b
fromIntegral) t
t GLint
level TexLevelParameter
TextureCompressedImageSize
         else Maybe GLint -> IO (Maybe GLint)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GLint
forall a. Maybe a
Nothing

textureProxyOK :: ParameterizedTextureTarget t => TextureQuery t Bool
textureProxyOK :: forall t. ParameterizedTextureTarget t => TextureQuery t Bool
textureProxyOK t
t GLint
level =
   IO Bool -> IO Bool
forall a. IO a -> IO a
makeGettableStateVar (IO Bool -> IO Bool) -> IO Bool -> IO Bool
forall a b. (a -> b) -> a -> b
$
      (GLint -> Bool) -> GLenum -> GLint -> TexLevelParameter -> IO Bool
forall a.
(GLint -> a) -> GLenum -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteri GLint -> Bool
forall a. (Eq a, Num a) => a -> Bool
unmarshalGLboolean (t -> GLenum
forall t. ParameterizedTextureTarget t => t -> GLenum
marshalParameterizedTextureTargetProxy t
t) GLint
level TexLevelParameter
TextureWidth

textureRGBATypes :: QueryableTextureTarget t =>  TextureQuery t (Color4 (Maybe DataRepresentation))
textureRGBATypes :: forall t.
QueryableTextureTarget t =>
TextureQuery t (Color4 (Maybe DataRepresentation))
textureRGBATypes t
t GLint
level =
   IO (Color4 (Maybe DataRepresentation))
-> IO (Color4 (Maybe DataRepresentation))
forall a. IO a -> IO a
makeGettableStateVar (IO (Color4 (Maybe DataRepresentation))
 -> IO (Color4 (Maybe DataRepresentation)))
-> IO (Color4 (Maybe DataRepresentation))
-> IO (Color4 (Maybe DataRepresentation))
forall a b. (a -> b) -> a -> b
$
      (Maybe DataRepresentation
 -> Maybe DataRepresentation
 -> Maybe DataRepresentation
 -> Maybe DataRepresentation
 -> Color4 (Maybe DataRepresentation))
-> IO (Maybe DataRepresentation)
-> IO (Maybe DataRepresentation)
-> IO (Maybe DataRepresentation)
-> IO (Maybe DataRepresentation)
-> IO (Color4 (Maybe DataRepresentation))
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 Maybe DataRepresentation
-> Maybe DataRepresentation
-> Maybe DataRepresentation
-> Maybe DataRepresentation
-> Color4 (Maybe DataRepresentation)
forall a. a -> a -> a -> a -> Color4 a
Color4
             (t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureRedType  )
             (t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureGreenType)
             (t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureBlueType )
             (t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureAlphaType)

getDataRepr :: QueryableTextureTarget t => t -> Level -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr :: forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr = (GLint -> Maybe DataRepresentation)
-> t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy (GLenum -> Maybe DataRepresentation
unmarshalDataRepresentation (GLenum -> Maybe DataRepresentation)
-> (GLint -> GLenum) -> GLint -> Maybe DataRepresentation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLint -> GLenum
forall a b. (Integral a, Num b) => a -> b
fromIntegral)

textureIntensityType :: QueryableTextureTarget t => TextureQuery t (Maybe DataRepresentation)
textureIntensityType :: forall t.
QueryableTextureTarget t =>
TextureQuery t (Maybe DataRepresentation)
textureIntensityType t
t GLint
level = IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation)
forall a. IO a -> IO a
makeGettableStateVar (IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation))
-> IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation)
forall a b. (a -> b) -> a -> b
$ t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureIntensityType

textureLuminanceType :: QueryableTextureTarget t =>  TextureQuery t (Maybe DataRepresentation)
textureLuminanceType :: forall t.
QueryableTextureTarget t =>
TextureQuery t (Maybe DataRepresentation)
textureLuminanceType t
t GLint
level = IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation)
forall a. IO a -> IO a
makeGettableStateVar (IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation))
-> IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation)
forall a b. (a -> b) -> a -> b
$ t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureLuminanceType

textureDepthType :: QueryableTextureTarget t =>  TextureQuery t (Maybe DataRepresentation)
textureDepthType :: forall t.
QueryableTextureTarget t =>
TextureQuery t (Maybe DataRepresentation)
textureDepthType t
t GLint
level = IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation)
forall a. IO a -> IO a
makeGettableStateVar (IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation))
-> IO (Maybe DataRepresentation) -> IO (Maybe DataRepresentation)
forall a b. (a -> b) -> a -> b
$ t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
forall t.
QueryableTextureTarget t =>
t -> GLint -> TexLevelParameter -> IO (Maybe DataRepresentation)
getDataRepr t
t GLint
level TexLevelParameter
TextureDepthType

getTexLevelParameteriNoProxy :: QueryableTextureTarget t => (GLint -> a) -> t -> Level -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy :: forall t a.
QueryableTextureTarget t =>
(GLint -> a) -> t -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteriNoProxy GLint -> a
f = (GLint -> a) -> GLenum -> GLint -> TexLevelParameter -> IO a
forall a.
(GLint -> a) -> GLenum -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteri GLint -> a
f (GLenum -> GLint -> TexLevelParameter -> IO a)
-> (t -> GLenum) -> t -> GLint -> TexLevelParameter -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> GLenum
forall t. QueryableTextureTarget t => t -> GLenum
marshalQueryableTextureTarget

getTexLevelParameteri :: (GLint -> a) -> GLenum -> Level -> TexLevelParameter -> IO a
getTexLevelParameteri :: forall a.
(GLint -> a) -> GLenum -> GLint -> TexLevelParameter -> IO a
getTexLevelParameteri GLint -> a
f GLenum
t GLint
level TexLevelParameter
p =
   GLint -> (Ptr GLint -> IO a) -> IO a
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with GLint
0 ((Ptr GLint -> IO a) -> IO a) -> (Ptr GLint -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr GLint
buf -> do
      GLenum -> GLint -> GLenum -> Ptr GLint -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLint -> GLenum -> Ptr GLint -> m ()
glGetTexLevelParameteriv GLenum
t GLint
level (TexLevelParameter -> GLenum
marshalTexLevelParameter TexLevelParameter
p) Ptr GLint
buf
      (GLint -> a) -> Ptr GLint -> IO a
forall a b. Storable a => (a -> b) -> Ptr a -> IO b
peek1 GLint -> a
f Ptr GLint
buf