Copyright | (c) capsjac 2014 |
---|---|
License | LGPL-3 (see the file LICENSE) |
Safe Haskell | None |
Language | Haskell2010 |
The neat and easy to use wrapper for OpenGL EmbedSystems (ES). The wrapper is optimised for mobile and have small footprint. Assuming OpenGL ES 2.0 or any later version, however, also works with OpenGL 4.1/4.3+ on desktop.
- type GL = IO
- forkGL :: IO Bool -> GL () -> GL () -> IO ThreadId
- stopGL :: IO ()
- endFrameGL :: IO ()
- runGL :: GL () -> IO ()
- withGL :: GL a -> IO (Future' a)
- resetDrawQueue :: IO ()
- glLog :: String -> IO ()
- glReadLogs :: IO [String]
- glLogContents :: IO [String]
- flushCommandQ :: IO ()
- finishCommands :: IO ()
- glFrameCount :: IO Int64
- glFlipping :: IO Bool
- framesize :: Int -> Int -> IO ()
- glDraw :: Typeable p => DrawMode -> Program p -> [RenderConfig] -> [UniformAssignment p] -> VertexArray p -> VertexPicker -> GL Bool
- data DrawMode
- drawPoints :: DrawMode
- drawLines :: DrawMode
- drawLineLoop :: DrawMode
- drawLineStrip :: DrawMode
- drawTriangles :: DrawMode
- triangleStrip :: DrawMode
- triangleFan :: DrawMode
- type RenderConfig = GL ()
- renderTo :: RenderConfig -> GL ()
- data Shader
- vertexShader :: GLName -> ByteString -> Shader
- fragmentShader :: GLName -> ByteString -> Shader
- pixelShader :: GLName -> ByteString -> Shader
- computeShader :: GLName -> ByteString -> Shader
- geometryShader :: GLName -> ByteString -> Shader
- tessellationEvalS :: GLName -> ByteString -> Shader
- tessellationCtrlS :: GLName -> ByteString -> Shader
- data Program p
- module Data.Typeable
- data TransformFeedback
- type ProgramBinary = ByteString
- glCompile :: Typeable p => TransformFeedback -> [Shader] -> (Program p -> Int -> String -> Maybe ProgramBinary -> GL ()) -> GL (Progress [String] (Program p))
- glValidate :: Program p -> GL String
- data Uniform p a
- uniform :: forall p a. (UnifVal a, Typeable p) => GLName -> IO (Uniform p a)
- ($=) :: UnifVal a => Uniform p a -> a -> UniformAssignment p
- class UnifVal a
- type UniformAssignment p = GL ()
- data Attrib p a
- attrib :: forall p a. (VertexAttribute a, Typeable p) => GLName -> IO (Attrib p a)
- normalized :: Attrib p a -> Attrib p a
- divisor :: Attrib p a -> Word32 -> Attrib p a
- (&=) :: AttrStruct a p b => a -> Buffer b -> SetVertexAttr p
- data VertexArray p
- glVA :: [SetVertexAttr p] -> GL (VertexArray p)
- class VertexAttribute a
- class AttrStruct a p b | a -> p
- type SetVertexAttr p = GL ()
- constAttrib :: VertexAttribute a => Attrib p a -> a -> SetVertexAttr p
- data VertexPicker
- takeFrom :: Int32 -> Int32 -> VertexPicker
- takeFromInstanced :: Int32 -> Int32 -> Int32 -> VertexPicker
- takeFromMany :: [(Int32, Int32)] -> VertexPicker
- class VertexIx a
- byIndex :: VertexIx a => Buffer a -> Int32 -> Int32 -> VertexPicker
- byIndexInstanced :: VertexIx a => Buffer a -> Int32 -> Int32 -> Int32 -> VertexPicker
- byIndices :: VertexIx a => Buffer a -> [(Int32, Int32)] -> VertexPicker
- byIndexLimited :: VertexIx a => Buffer a -> Int32 -> Int32 -> Word32 -> Word32 -> VertexPicker
- drawCallSequence :: [VertexPicker] -> VertexPicker
Documentation
Lifecycle
endFrameGL :: IO () Source
resetDrawQueue :: IO () Source
drawQueue may have drawcalls that use previous context, so make it sure they are removed from the queue.
glReadLogs :: IO [String] Source
glLogContents :: IO [String] Source
flushCommandQ :: IO () Source
finishCommands :: IO () Source
glFlipping :: IO Bool Source
Draw Operation
Clear Screen
Draw
glDraw :: Typeable p => DrawMode -> Program p -> [RenderConfig] -> [UniformAssignment p] -> VertexArray p -> VertexPicker -> GL Bool Source
Draw Mode
Graphics State
type RenderConfig = GL () Source
renderTo :: RenderConfig -> GL () Source
renderTo $ do bindFb defaultFramebuffer viewport $ V4 0 0 512 512 depthRange $ V2 0.1 10.0 begin culling cullFace hideBack
Programmable Shader
vertexShader :: GLName -> ByteString -> Shader Source
fragmentShader :: GLName -> ByteString -> Shader Source
pixelShader :: GLName -> ByteString -> Shader Source
Same as fragmentShader
computeShader :: GLName -> ByteString -> Shader Source
Compute shader requires ES3.1+
geometryShader :: GLName -> ByteString -> Shader Source
Geometry shader requires GL_EXT_geometry_shader (ES3.1)
tessellationEvalS :: GLName -> ByteString -> Shader Source
Tessellation Shader requires GL_EXT_tessellation_shader (ES3.1)
tessellationCtrlS :: GLName -> ByteString -> Shader Source
Tessellation Shader requires GL_EXT_tessellation_shader (ES3.1)
module Data.Typeable
data TransformFeedback Source
type ProgramBinary = ByteString Source
glCompile :: Typeable p => TransformFeedback -> [Shader] -> (Program p -> Int -> String -> Maybe ProgramBinary -> GL ()) -> GL (Progress [String] (Program p)) Source
glValidate :: Program p -> GL String Source
glValidateProgram checks to see whether the executables contained in program can execute given the current OpenGL state.
Uniform Variable
($=) :: UnifVal a => Uniform p a -> a -> UniformAssignment p infix 0 Source
UnifVal Double | |
UnifVal Float | |
UnifVal Int32 | |
UnifVal Word32 | |
UnifVal UVec4 | |
UnifVal UVec3 | |
UnifVal UVec2 | |
UnifVal IVec4 | |
UnifVal IVec3 | |
UnifVal IVec2 | |
UnifVal Vec4 | |
UnifVal Vec3 | |
UnifVal Vec2 | |
UnifVal DVec4 | |
UnifVal DVec3 | |
UnifVal DVec2 | |
UnifVal [Double] | |
UnifVal [Float] | |
UnifVal [Int32] | |
UnifVal [Word32] | |
(Distributive g, Functor f, UnifMat (f (g a)), Storable (g (f a))) => UnifVal [f (g a)] | Array of matrix Not tested!!! |
UnifVal [UVec4] | |
UnifVal [UVec3] | |
UnifVal [UVec2] | |
UnifVal [IVec4] | |
UnifVal [IVec3] | |
UnifVal [IVec2] | |
UnifVal [Vec4] | |
UnifVal [Vec3] | |
UnifVal [Vec2] | |
UnifVal [DVec4] | |
UnifVal [DVec3] | |
UnifVal [DVec2] | |
(Distributive g, Functor f, UnifMat (f (g a)), Storable (g (f a))) => UnifVal (f (g a)) | Matrix Not tested!!! |
type UniformAssignment p = GL () Source
Vertex Attribute Array
Show (Attrib p a) | |
(VertexAttribute a, (~) * (Vectorize a) (v a'), (~) * (Vectorize b) (v b'), KnownNat (VDim v), AttrElement b', VertexAttributeArray a' b') => AttrStruct (Attrib p a) p b | |
(VertexAttribute (f (g a)), Applicative g, Floating a, FoldableWithIndex (E V4) g, KnownNat (VDim f), KnownNat (SizeOf (f a)), KnownNat (SizeOf (f (g a))), AttrElement a) => AttrStruct (Attrib p (f (g a))) p (f (g a)) |
attrib :: forall p a. (VertexAttribute a, Typeable p) => GLName -> IO (Attrib p a) Source
normalized color divisor
1 &= buffer
normalized :: Attrib p a -> Attrib p a Source
(&=) :: AttrStruct a p b => a -> Buffer b -> SetVertexAttr p infix 0 Source
data VertexArray p Source
glVA :: [SetVertexAttr p] -> GL (VertexArray p) Source
class VertexAttribute a Source
GLSL vertex attribute type
VertexAttribute Double | |
VertexAttribute Float | |
VertexAttribute Int32 | |
VertexAttribute Word32 | |
VertexAttribute UVec4 | |
VertexAttribute UVec3 | |
VertexAttribute UVec2 | |
VertexAttribute IVec4 | |
VertexAttribute IVec3 | |
VertexAttribute IVec2 | |
VertexAttribute Vec4 | |
VertexAttribute Vec3 | |
VertexAttribute Vec2 | |
VertexAttribute DVec4 | |
VertexAttribute DVec3 | |
VertexAttribute DVec2 | |
(Functor f, Floating a, Distributive g, VertexAttribute (f a), FoldableWithIndex (E V4) g) => VertexAttribute (f (g a)) | Matrices Not tested!!! |
VertexAttribute a => VertexAttribute (V1 a) |
class AttrStruct a p b | a -> p Source
A set of VertexAttribute
s packed in a Buffer
(VertexAttribute a, (~) * (Vectorize a) (v a'), (~) * (Vectorize b) (v b'), KnownNat (VDim v), AttrElement b', VertexAttributeArray a' b') => AttrStruct (Attrib p a) p b | |
(VertexAttribute (f (g a)), Applicative g, Floating a, FoldableWithIndex (E V4) g, KnownNat (VDim f), KnownNat (SizeOf (f a)), KnownNat (SizeOf (f (g a))), AttrElement a) => AttrStruct (Attrib p (f (g a))) p (f (g a)) |
type SetVertexAttr p = GL () Source
Constant Vertex Attribute
constAttrib :: VertexAttribute a => Attrib p a -> a -> SetVertexAttr p Source
Texture
Vertex Picker
data VertexPicker Source
takeFrom :: Int32 -> Int32 -> VertexPicker Source
takeFromInstanced :: Int32 -> Int32 -> Int32 -> VertexPicker Source
takeFromMany :: [(Int32, Int32)] -> VertexPicker Source
byIndexInstanced :: VertexIx a => Buffer a -> Int32 -> Int32 -> Int32 -> VertexPicker Source
byIndexLimited :: VertexIx a => Buffer a -> Int32 -> Int32 -> Word32 -> Word32 -> VertexPicker Source