module Graphics.Rendering.OpenGL.GL.TransformFeedback (
beginTransformFeedback, endTransformFeedback,
TransformFeedbackBufferMode(..), marshalTransformFeedbackBufferMode,
unmarshalTransformFeedbackBufferMode,
transformFeedbackBufferMode,
transformFeedbackVaryings,
setTransformFeedbackVaryings,
maxTransformFeedbackSeparateAttribs,
maxTransformFeedbackInterleavedComponents,
maxTransformFeedbackSeparateComponents
) where
import Data.StateVar
import Foreign.Marshal.Array
import Graphics.Rendering.OpenGL.GL.ByteString
import Graphics.Rendering.OpenGL.GL.DataType
import Graphics.Rendering.OpenGL.GL.PrimitiveMode
import Graphics.Rendering.OpenGL.GL.PrimitiveModeInternal
import Graphics.Rendering.OpenGL.GL.QueryUtils
import Graphics.Rendering.OpenGL.GL.Shaders.Program
import Graphics.Rendering.OpenGL.GL.Shaders.Variables
import Graphics.GL
beginTransformFeedback :: PrimitiveMode -> IO ()
beginTransformFeedback = glBeginTransformFeedback . marshalPrimitiveMode
endTransformFeedback :: IO ()
endTransformFeedback = glEndTransformFeedback
data TransformFeedbackBufferMode =
InterleavedAttribs
| SeparateAttribs
| SeperateAttribs
deriving ( Eq, Ord, Show )
{-# DEPRECATED SeperateAttribs "Use 'SeparateAttribs' instead." #-}
marshalTransformFeedbackBufferMode :: TransformFeedbackBufferMode -> GLenum
marshalTransformFeedbackBufferMode x = case x of
InterleavedAttribs -> GL_INTERLEAVED_ATTRIBS
SeparateAttribs -> GL_SEPARATE_ATTRIBS
SeperateAttribs -> GL_SEPARATE_ATTRIBS
unmarshalTransformFeedbackBufferMode :: GLenum -> TransformFeedbackBufferMode
unmarshalTransformFeedbackBufferMode x
| x == GL_INTERLEAVED_ATTRIBS = InterleavedAttribs
| x == GL_SEPARATE_ATTRIBS = SeparateAttribs
| otherwise = error $ "unmarshalTransformFeedbackBufferMode: illegal value " ++ show x
maxTransformFeedbackSeparateAttribs :: GettableStateVar GLint
maxTransformFeedbackSeparateAttribs = makeGettableStateVar $
getInteger1 fromIntegral GetMaxTransformFeedbackSeparateAttribs
maxTransformFeedbackInterleavedComponents :: GettableStateVar GLint
maxTransformFeedbackInterleavedComponents = makeGettableStateVar $
getInteger1 fromIntegral GetMaxTransformFeedbackInterleavedComponents
maxTransformFeedbackSeparateComponents :: GettableStateVar GLint
maxTransformFeedbackSeparateComponents = makeGettableStateVar $
getInteger1 fromIntegral GetMaxTransformFeedbackSeparateComponents
setTransformFeedbackVaryings :: Program -> [String]
-> TransformFeedbackBufferMode -> IO ()
setTransformFeedbackVaryings (Program program) sts tfbm = do
ptSts <- mapM (\x -> withGLstring x return) sts
stsPtrs <- newArray ptSts
glTransformFeedbackVaryings program (fromIntegral . length $ sts) stsPtrs
(marshalTransformFeedbackBufferMode tfbm)
transformFeedbackBufferMode
:: Program -> GettableStateVar TransformFeedbackBufferMode
transformFeedbackBufferMode = programVar1
(unmarshalTransformFeedbackBufferMode . fromIntegral)
TransformFeedbackBufferMode
numTransformFeedbackVaryings :: Program -> GettableStateVar GLuint
numTransformFeedbackVaryings =
programVar1 fromIntegral TransformFeedbackVaryings
transformFeedbackVaryingMaxLength :: Program -> GettableStateVar GLsizei
transformFeedbackVaryingMaxLength
= programVar1 fromIntegral TransformFeedbackVaryingMaxLength
transformFeedbackVaryings :: Program -> GettableStateVar [(GLint, DataType, String)]
transformFeedbackVaryings =
activeVars
numTransformFeedbackVaryings
transformFeedbackVaryingMaxLength
glGetTransformFeedbackVarying
unmarshalDataType