-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Miscellaneous OpenGL utilities.
--
-- Helpers for working with shaders, buffer objects, and textures in
-- OpenGL.
@package GLUtil
@version 0.2
-- | A thin layer over OpenGL 3.1+ vertex array objects.
module Graphics.GLUtil.VertexArrayObjects
-- | A vertex array object captures OpenGL state needed for drawing a
-- vertex array. It encapsulates the binding of an array buffer and an
-- element buffer, as well as vertex attribute setup.
newtype VertexArrayObject
VertexArrayObject :: GLuint -> VertexArrayObject
-- | Short alias.
type VAO = VertexArrayObject
-- | Allocate a VertexArrayObject, and initialize it with the
-- provided action. This action should bind the buffer data, index data
-- (if necessary), and setup vertex attributes.
makeVAO :: IO () -> IO VertexArrayObject
-- | Delete a VertexArrayObject. Do not use the VAO after running
-- this action!
deleteVAO :: VertexArrayObject -> IO ()
-- | Bind a VertexArrayObject, or ensure that no VAO is bound.
bindVertexArray :: Maybe VertexArrayObject -> IO ()
-- | Miscellaneous utilities for dealing with OpenGL errors.
module Graphics.GLUtil.GLError
-- | Check OpenGL error flags and print them on stderr.
printError :: IO ()
-- | Check OpenGL error flags and print them on stderr with the
-- given message as a prefix. If there are no errors, nothing is printed.
printErrorMsg :: String -> IO ()
-- | Throw an exception if there is an OpenGL error.
throwError :: IO ()
-- | An exception type for OpenGL errors.
data GLError
-- | Throw an exception if there is an OpenGL error. The exception's error
-- message is prefixed with the supplied String.
throwErrorMsg :: String -> IO ()
instance Typeable GLError
instance Show GLError
instance Exception GLError
-- | Utilities for loading texture data.
module Graphics.GLUtil.Textures
-- | Pixel format of image data.
data TexColor
TexMono :: TexColor
TexRGB :: TexColor
TexBGR :: TexColor
-- | A basic texture information record.
data TexInfo a
TexInfo :: GLsizei -> GLsizei -> TexColor -> a -> TexInfo a
texWidth :: TexInfo a -> GLsizei
texHeight :: TexInfo a -> GLsizei
texColor :: TexInfo a -> TexColor
texData :: TexInfo a -> a
-- | Helper for constructing a TexInfo using Haskell Ints for
-- image dimensions.
texInfo :: Int -> Int -> TexColor -> a -> TexInfo a
-- | Open mapping from Haskell types to OpenGL types.
class Storable a => HasGLType a
glType :: HasGLType a => a -> DataType
-- | Class for containers of texture data.
class HasGLType (Elem a) => IsPixelData a where type family Elem a
withPixels :: IsPixelData a => a -> (Ptr (Elem a) -> IO c) -> IO c
-- | Wrapper whose IsPixelData instance treats the pointer
-- underlying a ByteString as an array of Word16s.
newtype ShortString
ShortString :: ByteString -> ShortString
-- | Create a new 2D texture with data from a TexInfo.
loadTexture :: IsPixelData a => TexInfo a -> IO (TextureObject)
-- | Replace a 2D texture's pixel data with data from a TexInfo.
reloadTexture :: IsPixelData a => TextureObject -> TexInfo a -> IO ()
instance IsPixelData ShortString
instance IsPixelData ByteString
instance HasGLType b => IsPixelData (Vector b)
instance HasGLType b => IsPixelData (StorableArray i b)
instance HasGLType b => IsPixelData (ForeignPtr b)
instance HasGLType b => IsPixelData (Ptr b)
instance HasGLType b => IsPixelData [b]
instance HasGLType Float
instance HasGLType Word16
instance HasGLType Word8
instance HasGLType Int
-- | Utilities for working with fragment and vertex shader programs.
module Graphics.GLUtil.Shaders
-- | Load a shader program from a file.
loadShader :: Shader s => FilePath -> IO s
-- | Link vertex and fragment shaders into a Program.
linkShaderProgram :: [VertexShader] -> [FragmentShader] -> IO Program
-- | Work with a named uniform shader parameter. Note that this looks up
-- the variable name on each access, so uniform parameters that will be
-- accessed frequently should instead be resolved to a
-- UniformLocation.
namedUniform :: Uniform a => String -> StateVar a
-- | Set a UniformLocation to a scalar value.
uniformScalar :: UniformComponent a => UniformLocation -> SettableStateVar a
-- | Set a UniformLocation from a list representation of a
-- low-dimensional vector of GLfloats. Only 2, 3, and 4
-- dimensional vectors are supported.
uniformVec :: UniformLocation -> SettableStateVar [GLfloat]
-- | Set a uniform shader location from a nested list matrix
-- representation. Only 3x3 and 4x4 matrices are supported.
uniformMat :: UniformLocation -> SettableStateVar [[GLfloat]]
-- | Set a named uniform shader parameter from a nested list matrix
-- representation. Only 3x3 and 4x4 matrices are supported.
namedUniformMat :: String -> SettableStateVar [[GLfloat]]
-- | Set a uniform shader location with a 4x4 GLmatrix.
uniformGLMat4 :: UniformLocation -> SettableStateVar (GLmatrix GLfloat)
-- | Utilities for filling BufferObjects.
module Graphics.GLUtil.BufferObjects
-- | Allocate and fill a BufferObject from a list of
-- Storables.
makeBuffer :: Storable a => BufferTarget -> [a] -> IO BufferObject
-- | Allocate and fill a BufferObject from a list of
-- Storables whose length is explicitly given. This is useful when
-- the list is of known length, as it avoids a traversal to find the
-- length.
makeBufferLen :: Storable a => BufferTarget -> Int -> [a] -> IO BufferObject
-- | Allocate and fill a BufferObject with the given number of bytes
-- from the supplied pointer.
fromPtr :: BufferTarget -> Int -> Ptr a -> IO BufferObject
-- | Fill a buffer with a ByteString.
fromByteString :: BufferTarget -> ByteString -> IO BufferObject
-- | Fill a buffer with data from a ForeignPtr. The application
-- fromForeignPtr target len fptr fills a target
-- BufferTarget with len elements starting from
-- fptr.
fromForeignPtr :: Storable a => BufferTarget -> Int -> ForeignPtr a -> IO BufferObject
-- | Fill a buffer with data from a Vector.
fromVector :: Storable a => BufferTarget -> Vector a -> IO BufferObject
-- | Produce a Ptr value to be used as an offset of the given number
-- of bytes.
offsetPtr :: Int -> Ptr a
-- | A zero-offset Ptr.
offset0 :: Ptr a
-- | The main import that simply re-exports the various modules that make
-- up the GLUtil library.
module Graphics.GLUtil