{-# OPTIONS_HADDOCK hide #-}
module Graphics.Rendering.OpenGL.GL.QueryUtils.VertexAttrib (
AttribLocation(..), GetVertexAttribPName(..),
getVertexAttribInteger1, getVertexAttribEnum1, getVertexAttribBoolean1,
getVertexAttribFloat4, getVertexAttribIInteger4, getVertexAttribIuInteger4,
GetVertexAttribPointerPName(..), getVertexAttribPointer
) where
import Foreign.Marshal.Alloc
import Foreign.Marshal.Utils
import Foreign.Ptr
import Foreign.Storable
import Graphics.Rendering.OpenGL.GL.PeekPoke
import Graphics.GL
newtype AttribLocation = AttribLocation GLuint
deriving ( AttribLocation -> AttribLocation -> Bool
(AttribLocation -> AttribLocation -> Bool)
-> (AttribLocation -> AttribLocation -> Bool) -> Eq AttribLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttribLocation -> AttribLocation -> Bool
$c/= :: AttribLocation -> AttribLocation -> Bool
== :: AttribLocation -> AttribLocation -> Bool
$c== :: AttribLocation -> AttribLocation -> Bool
Eq, Eq AttribLocation
Eq AttribLocation =>
(AttribLocation -> AttribLocation -> Ordering)
-> (AttribLocation -> AttribLocation -> Bool)
-> (AttribLocation -> AttribLocation -> Bool)
-> (AttribLocation -> AttribLocation -> Bool)
-> (AttribLocation -> AttribLocation -> Bool)
-> (AttribLocation -> AttribLocation -> AttribLocation)
-> (AttribLocation -> AttribLocation -> AttribLocation)
-> Ord AttribLocation
AttribLocation -> AttribLocation -> Bool
AttribLocation -> AttribLocation -> Ordering
AttribLocation -> AttribLocation -> AttribLocation
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 :: AttribLocation -> AttribLocation -> AttribLocation
$cmin :: AttribLocation -> AttribLocation -> AttribLocation
max :: AttribLocation -> AttribLocation -> AttribLocation
$cmax :: AttribLocation -> AttribLocation -> AttribLocation
>= :: AttribLocation -> AttribLocation -> Bool
$c>= :: AttribLocation -> AttribLocation -> Bool
> :: AttribLocation -> AttribLocation -> Bool
$c> :: AttribLocation -> AttribLocation -> Bool
<= :: AttribLocation -> AttribLocation -> Bool
$c<= :: AttribLocation -> AttribLocation -> Bool
< :: AttribLocation -> AttribLocation -> Bool
$c< :: AttribLocation -> AttribLocation -> Bool
compare :: AttribLocation -> AttribLocation -> Ordering
$ccompare :: AttribLocation -> AttribLocation -> Ordering
$cp1Ord :: Eq AttribLocation
Ord, Int -> AttribLocation -> ShowS
[AttribLocation] -> ShowS
AttribLocation -> String
(Int -> AttribLocation -> ShowS)
-> (AttribLocation -> String)
-> ([AttribLocation] -> ShowS)
-> Show AttribLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttribLocation] -> ShowS
$cshowList :: [AttribLocation] -> ShowS
show :: AttribLocation -> String
$cshow :: AttribLocation -> String
showsPrec :: Int -> AttribLocation -> ShowS
$cshowsPrec :: Int -> AttribLocation -> ShowS
Show )
data GetVertexAttribPName =
GetVertexAttribArrayEnabled
| GetVertexAttribArraySize
| GetVertexAttribArrayStride
| GetVertexAttribArrayType
| GetVertexAttribArrayNormalized
| GetCurrentVertexAttrib
| GetVertexAttribArrayBufferBinding
| GetVertexAttribArrayInteger
marshalGetVertexAttribPName :: GetVertexAttribPName -> GLenum
marshalGetVertexAttribPName :: GetVertexAttribPName -> GLenum
marshalGetVertexAttribPName x :: GetVertexAttribPName
x = case GetVertexAttribPName
x of
GetVertexAttribArrayEnabled -> GLenum
GL_VERTEX_ATTRIB_ARRAY_ENABLED
GetVertexAttribArraySize -> GLenum
GL_VERTEX_ATTRIB_ARRAY_SIZE
GetVertexAttribArrayStride -> GLenum
GL_VERTEX_ATTRIB_ARRAY_STRIDE
GetVertexAttribArrayType -> GLenum
GL_VERTEX_ATTRIB_ARRAY_TYPE
GetVertexAttribArrayNormalized -> GLenum
GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
GetCurrentVertexAttrib -> GLenum
GL_CURRENT_VERTEX_ATTRIB
GetVertexAttribArrayBufferBinding -> GLenum
GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
GetVertexAttribArrayInteger -> GLenum
GL_VERTEX_ATTRIB_ARRAY_INTEGER
getVertexAttribInteger1 :: (GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribInteger1 :: (GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribInteger1 f :: GLint -> b
f (AttribLocation location :: GLenum
location) n :: GetVertexAttribPName
n = GLint -> (Ptr GLint -> IO b) -> IO b
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with 0 ((Ptr GLint -> IO b) -> IO b) -> (Ptr GLint -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \buf :: Ptr GLint
buf -> do
GLenum -> GLenum -> Ptr GLint -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLenum -> Ptr GLint -> m ()
glGetVertexAttribiv GLenum
location (GetVertexAttribPName -> GLenum
marshalGetVertexAttribPName GetVertexAttribPName
n) Ptr GLint
buf
(GLint -> b) -> Ptr GLint -> IO b
forall a b. Storable a => (a -> b) -> Ptr a -> IO b
peek1 GLint -> b
f Ptr GLint
buf
getVertexAttribEnum1 :: (GLenum -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribEnum1 :: (GLenum -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribEnum1 f :: GLenum -> b
f = (GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
forall b.
(GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribInteger1 (GLenum -> b
f (GLenum -> b) -> (GLint -> GLenum) -> GLint -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLint -> GLenum
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
getVertexAttribBoolean1 :: (GLboolean -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribBoolean1 :: (GLboolean -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribBoolean1 f :: GLboolean -> b
f = (GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
forall b.
(GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribInteger1 (GLboolean -> b
f (GLboolean -> b) -> (GLint -> GLboolean) -> GLint -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLint -> GLboolean
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
getVertexAttribFloat4 :: (GLfloat -> GLfloat -> GLfloat -> GLfloat -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribFloat4 :: (GLfloat -> GLfloat -> GLfloat -> GLfloat -> b)
-> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribFloat4 f :: GLfloat -> GLfloat -> GLfloat -> GLfloat -> b
f (AttribLocation location :: GLenum
location) n :: GetVertexAttribPName
n = (Ptr GLfloat -> IO b) -> IO b
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr GLfloat -> IO b) -> IO b) -> (Ptr GLfloat -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \buf :: Ptr GLfloat
buf -> do
GLenum -> GLenum -> Ptr GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLenum -> Ptr GLfloat -> m ()
glGetVertexAttribfv GLenum
location (GetVertexAttribPName -> GLenum
marshalGetVertexAttribPName GetVertexAttribPName
n) Ptr GLfloat
buf
(GLfloat -> GLfloat -> GLfloat -> GLfloat -> b)
-> Ptr GLfloat -> IO b
forall a b. Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
peek4 GLfloat -> GLfloat -> GLfloat -> GLfloat -> b
f Ptr GLfloat
buf
getVertexAttribIInteger4 :: (GLint -> GLint -> GLint -> GLint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribIInteger4 :: (GLint -> GLint -> GLint -> GLint -> b)
-> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribIInteger4 f :: GLint -> GLint -> GLint -> GLint -> b
f (AttribLocation location :: GLenum
location) n :: GetVertexAttribPName
n = (Ptr GLint -> IO b) -> IO b
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr GLint -> IO b) -> IO b) -> (Ptr GLint -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \buf :: Ptr GLint
buf -> do
GLenum -> GLenum -> Ptr GLint -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLenum -> Ptr GLint -> m ()
glGetVertexAttribIiv GLenum
location (GetVertexAttribPName -> GLenum
marshalGetVertexAttribPName GetVertexAttribPName
n) Ptr GLint
buf
(GLint -> GLint -> GLint -> GLint -> b) -> Ptr GLint -> IO b
forall a b. Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
peek4 GLint -> GLint -> GLint -> GLint -> b
f Ptr GLint
buf
getVertexAttribIuInteger4 :: (GLuint -> GLuint -> GLuint -> GLuint -> b) -> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribIuInteger4 :: (GLenum -> GLenum -> GLenum -> GLenum -> b)
-> AttribLocation -> GetVertexAttribPName -> IO b
getVertexAttribIuInteger4 f :: GLenum -> GLenum -> GLenum -> GLenum -> b
f (AttribLocation location :: GLenum
location) n :: GetVertexAttribPName
n = (Ptr GLenum -> IO b) -> IO b
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr GLenum -> IO b) -> IO b) -> (Ptr GLenum -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \buf :: Ptr GLenum
buf -> do
GLenum -> GLenum -> Ptr GLenum -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLenum -> GLenum -> Ptr GLenum -> m ()
glGetVertexAttribIuiv GLenum
location (GetVertexAttribPName -> GLenum
marshalGetVertexAttribPName GetVertexAttribPName
n) Ptr GLenum
buf
(GLenum -> GLenum -> GLenum -> GLenum -> b) -> Ptr GLenum -> IO b
forall a b. Storable a => (a -> a -> a -> a -> b) -> Ptr a -> IO b
peek4 GLenum -> GLenum -> GLenum -> GLenum -> b
f Ptr GLenum
buf
data GetVertexAttribPointerPName =
VertexAttribArrayPointer
marshalGetVertexAttribPointerPName :: GetVertexAttribPointerPName -> GLenum
marshalGetVertexAttribPointerPName :: GetVertexAttribPointerPName -> GLenum
marshalGetVertexAttribPointerPName x :: GetVertexAttribPointerPName
x = case GetVertexAttribPointerPName
x of
VertexAttribArrayPointer -> GLenum
GL_VERTEX_ATTRIB_ARRAY_POINTER
getVertexAttribPointer :: AttribLocation -> GetVertexAttribPointerPName -> IO (Ptr a)
getVertexAttribPointer :: AttribLocation -> GetVertexAttribPointerPName -> IO (Ptr a)
getVertexAttribPointer (AttribLocation location :: GLenum
location) n :: GetVertexAttribPointerPName
n = Ptr a -> (Ptr (Ptr a) -> IO (Ptr a)) -> IO (Ptr a)
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Ptr a
forall a. Ptr a
nullPtr ((Ptr (Ptr a) -> IO (Ptr a)) -> IO (Ptr a))
-> (Ptr (Ptr a) -> IO (Ptr a)) -> IO (Ptr a)
forall a b. (a -> b) -> a -> b
$ \buf :: Ptr (Ptr a)
buf -> do
GLenum -> GLenum -> Ptr (Ptr a) -> IO ()
forall (m :: * -> *) a.
MonadIO m =>
GLenum -> GLenum -> Ptr (Ptr a) -> m ()
glGetVertexAttribPointerv GLenum
location (GetVertexAttribPointerPName -> GLenum
marshalGetVertexAttribPointerPName GetVertexAttribPointerPName
n) Ptr (Ptr a)
buf
Ptr (Ptr a) -> IO (Ptr a)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr a)
buf