Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newVAO :: IO VAO
- bindVAO :: VAO -> IO ()
- deleteVAO :: VAO -> IO ()
- data VAO
- newVBO :: Vector Word8 -> UsageHint -> IO VBO
- newElementArray :: Vector Word8 -> UsageHint -> IO ElementArray
- bindVBO :: VBO -> IO ()
- bindElementArray :: ElementArray -> IO ()
- updateVBO :: Vector Word8 -> Int -> IO ()
- updateElementArray :: Vector Word8 -> Int -> IO ()
- deleteBufferObject :: BufferObject a => a -> IO ()
- data VBO
- data ElementArray
- data UsageHint
- data IndexFormat
- newProgram :: String -> String -> IO Program
- newProgramSafe :: String -> String -> IO (Either ProgramError Program)
- useProgram :: Program -> IO ()
- deleteProgram :: Program -> IO ()
- setUniform1f :: String -> [Float] -> IO ()
- setUniform2f :: String -> [V2 Float] -> IO ()
- setUniform3f :: String -> [V3 Float] -> IO ()
- setUniform4f :: String -> [V4 Float] -> IO ()
- setUniform1i :: String -> [Int] -> IO ()
- setUniform2i :: String -> [V2 Int] -> IO ()
- setUniform3i :: String -> [V3 Int] -> IO ()
- setUniform4i :: String -> [V4 Int] -> IO ()
- setUniform22 :: String -> [M22 Float] -> IO ()
- setUniform33 :: String -> [M33 Float] -> IO ()
- setUniform44 :: String -> [M44 Float] -> IO ()
- data Program
- data ProgramError
- setVertexAttributeLayout :: VertexAttributeLayout -> IO ()
- type VertexAttributeLayout = [LayoutElement]
- data LayoutElement
- data ComponentFormat
- newTexture2D :: InternalFormat a => Vector Word8 -> Dimensions -> IO (Tex2D a)
- newCubeMap :: InternalFormat a => Cube (Vector Word8, Dimensions) -> IO (CubeMap a)
- newEmptyTexture2D :: InternalFormat a => Int -> Int -> IO (Tex2D a)
- newEmptyCubeMap :: InternalFormat a => Int -> Int -> IO (CubeMap a)
- deleteTexture :: Texture a => a -> IO ()
- setActiveTextureUnit :: Enum a => a -> IO ()
- bindTexture2D :: Tex2D a -> IO ()
- bindTextureCubeMap :: CubeMap a -> IO ()
- setTex2DFiltering :: Filtering -> IO ()
- setCubeMapFiltering :: Filtering -> IO ()
- setTex2DWrapping :: Wrapping -> IO ()
- setCubeMapWrapping :: Wrapping -> IO ()
- data Tex2D a
- data CubeMap a
- data Dimensions = Dimensions {
- imageWidth :: Int
- imageHeight :: Int
- data Cube a = Cube {}
- type Side = forall a. Cube a -> a
- data Filtering
- data Wrapping
- drawPoints :: Int -> IO ()
- drawLines :: Int -> IO ()
- drawLineStrip :: Int -> IO ()
- drawLineLoop :: Int -> IO ()
- drawTriangles :: Int -> IO ()
- drawTriangleStrip :: Int -> IO ()
- drawTriangleFan :: Int -> IO ()
- drawIndexedPoints :: Int -> IndexFormat -> IO ()
- drawIndexedLines :: Int -> IndexFormat -> IO ()
- drawIndexedLineStrip :: Int -> IndexFormat -> IO ()
- drawIndexedLineLoop :: Int -> IndexFormat -> IO ()
- drawIndexedTriangles :: Int -> IndexFormat -> IO ()
- drawIndexedTriangleStrip :: Int -> IndexFormat -> IO ()
- drawIndexedTriangleFan :: Int -> IndexFormat -> IO ()
- enableColorWriting :: IO ()
- disableColorWriting :: IO ()
- clearColorBuffer :: (Float, Float, Float) -> IO ()
- enableDepthTest :: IO ()
- disableDepthTest :: IO ()
- clearDepthBuffer :: IO ()
- enableStencil :: Stencil -> IO ()
- disableStencil :: IO ()
- clearStencilBuffer :: IO ()
- basicStencil :: Stencil
- data Stencil = Stencil {
- func :: StencilFunc
- ref :: Int
- mask :: Word
- onStencilFail :: StencilOp
- onDepthFail :: StencilOp
- onBothPass :: StencilOp
- data StencilFunc
- = Never
- | Less
- | LessOrEqual
- | Greater
- | GreaterOrEqual
- | Equal
- | NotEqual
- | Always
- data StencilOp
- enableScissorTest :: Viewport -> IO ()
- disableScissorTest :: IO ()
- data Culling
- enableCulling :: Culling -> IO ()
- disableCulling :: IO ()
- enableBlending :: Blending -> IO ()
- disableBlending :: IO ()
- basicBlending :: Blending
- data Blending = Blending {
- sFactor :: BlendFactor
- dFactor :: BlendFactor
- blendFunc :: BlendEquation
- blendColor :: (Float, Float, Float, Float)
- data BlendFactor
- data BlendEquation
- data Viewport = Viewport {}
- setViewport :: Viewport -> IO ()
- data DefaultFramebuffer
- data FBO
- bindFramebuffer :: Framebuffer a => a -> IO ()
- newFBO :: IO FBO
- attachTex2D :: Attachable a => Tex2D a -> IO ()
- attachCubeMap :: Attachable a => CubeMap a -> Side -> IO ()
- attachRBO :: Attachable a => RBO a -> IO ()
- deleteFBO :: FBO -> IO ()
- data RBO a
- newRBO :: InternalFormat a => Int -> Int -> IO (RBO a)
- deleteRBO :: RBO a -> IO ()
- data GLError
- getGLError :: IO (Maybe GLError)
- data Alpha
- data Luminance
- data LuminanceAlpha
- data RGB
- data RGBA
- data Depth24
- data Depth24Stencil8
- class InternalFormat a where
- internalFormat :: (Eq b, Num b) => proxy a -> b
- class Framebuffer a where
- framebufferName :: Num b => a -> b
- class GLObject a => Texture a
- class InternalFormat a => Attachable a where
- attachPoint :: (Eq b, Num b) => proxy a -> b
In a Nutshell
Overview
OpenGL is a graphics rendering interface. This library exposes a vastly simplified subset of OpenGL that is hopefully still complete enough for many purposes, such as following tutorials, making simple games, and demos. In particular the intention is to concentrate on a subset of OpenGL 3.2 (Core Profile) roughly corresponding to ES 2.0.
A second primary purpose is to document the complex model behind the interface in a way that is more elaborate than tutorials and more concise than the spec. As such, this is an experimental project to aid my own process of understanding OpenGL. It seems that understanding the entire picture up-front is the only way to get started, so this should also serve as a quick reference guide to the core commands and concepts.
This library uses the gl
package for raw bindings to OpenGL and the
linear
package for matrices.
Objects
Objects may be created and destroyed by client code. They include:
Binding Targets
Objects are referenced with integers (called names in GL), so binding targets can be thought of as global variables to put those references. Many operations implicitly read from these globals to determine what the target object of the operation is. They include:
- Vertex array binding target (for VAO)
- Buffer binding targets (ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER)
- Texture binding targets (TEXTURE_2D and TEXTURE_CUBE_MAP)
- Framebuffer binding target (for FBO)
(not binding targets but similar)
- Shader program "in use"
- Texture units
- Current active texture unit
- Image attachment points of an FBO
Shader Programs
The role of the second half of a shader program, the fragment shader, is to compute the color and depth of pixels covered by rasterized primitives (points, lines, and triangles) in the process of rendering. The role of the first half of the program (vertex program) is to arrange the vertices of those primitives somewhere in clip space. Where these vertices and their attributes come from in the first place is determined by the VAO bound to the vertex array binding target. The program may also make use of uniform variables and texture units assigned by client code before rendering (but in a process completely separate from configuring the VAO). At most one Program can be "in use" at a time.
VAO
The VAO is essential. At least one VAO must be created and bound to the vertex array binding target before rendering, before configuring a program's vertex attributes. Here is why: the VAO stores the association between vertex inputs in the program and a VBO from which to pipe input from. It also stores the format of the VBO data, which is otherwise just a big blob. Finally, the VAO stores the state of the element array binding target used for indexed rendering.
After installing a program with useProgram
and binding a source VBO
to the array buffer binding target (bindVBO
) then the bound VAO can be
updated (setVertexAttributeLayout
) with new vertex attribute information.
After this, the VBO can be rebound to configure a different set of inputs
with a different source. Many VAOs can be created and swapped out to pipe
vertex data in different ways to different programs (or the same program).
When a VAO is bound (bindVAO
) it restores the state of the element array
binding target. For this reason you can think of that binding target as
simply being a function of the VAO itself rather than a separate global
state.
Uniforms and Samplers (Textures)
Programs may also have uniform variables and "sampler uniforms" as
input. Uniforms are accessible from the vertex or fragment shader part of
the program but their values are fixed during the course of a rendering
command. They can be set and reset with the setUniform family (ex.
setUniform1f
), which updates the current program object with new uniform
values. Among other things, updating the uniforms each frame is the main
way to animate a scene.
Samplers are textures that the shader can interpolate to get "in between" values. The texture a sampler uses is determined by the contents of the texture unit that that sampler points to. The sampler is a uniform with an integer type. This integer is the texture unit to use. The word texture should not be construed to mean a color image. Shaders can make use of many kinds of multi-dimensional data that happen to be available through the samplers.
Texture Objects and Texture Units
Before a shader can use a texture it must be assigned to a texture unit.
First set the active texture unit to the desired unit number
(setActiveTextureUnit
) then bind the texture object to one of the
two texture binding targets, depending on what kind of texture it is (2D
or cubemap). Binding a texture has the side effect of assigning it to the
active texture unit.
Custom Framebuffers
It is possible (and important in many techniques) to utilize an
off-screen render target. To do this create an FBO (newFBO
), bind it to
the framebuffer binding target (bindFramebuffer
) and attach a color
image object (texture or renderbuffer object). If necessary a depth
image or combination depth-stencil image can be attached as well. If no
color image is attached then the FBO is incomplete and rendering will be
an error. After rendering to an FBO any textures that were attached can
be used in a second pass by assigning them to a texture unit. Watch out
for feedback loops accidentally sampling a texture that is also being
rendered to at the same time!
A renderbuffer object is a minor character to be used when you do not expect to use the results of rendering but need an image anyway. For example you may need a depth buffer to do depth testing, or you may want to ignore the (required for rendering to work at all) color buffer.
Images and Image Formats
FBOs have attachment points for images. A texture serves as an image
and a renderbuffer object serves as an image. Images have an "internal
format" which describes the size and interpretation of pixel components.
There are seven internal formats, five of which are color image formats
such as grayscale and RGB. The other two are the depth buffer format and
the combination depth-stencil format. RBOs (newRBO
) and empty textures
(newEmptyTexture2D
, newEmptyCubeMap
) can be created with any of these
formats.
(The above is a gross simplification of OpenGL's image formats. I should probably revise, because it may greatly improve performance to use some of the 16-bit color formats rather than 32. Also HDR color format.)
Depth Testing and Stencil Testing
The depth test and stencil test use extra buffers in parallel with the color buffer to cause regions of pixels to not show. It does this by making a comparison between the depth each pixel and the value present in those buffers, then updating the buffers as necessary. The stencil test in particular has many configurable options. See the respective modules for the Graphics.GL.Low.Depth and Graphics.GL.Low.Stencil tests.
Scissor Test
The scissor test, if enabled (enableScissorTest
), disallows all
rendering outside of a rectangle region of the window called the scissor
box.
Coordinate Systems (Mappings)
There are three transformation mechanisms which work together to get raw vertex data from VBOs to rasterized primitives somewhere on the window. You can imagine four coordinate systems between these three transformations if you want to.
- The vertex shader takes vertex positions as specified in vertex attributes to clip space. This is how the client code specifies a camera, movement of objects, and perspective.
- The perspective division or "W-divide" takes vertices from clip space and maps them to normalized device coordinates (NDC) by dividing all the components of the vertex by that vertex's W component. This allows a perspective effect to be accomplished in the shader by modifying the W components. You can't configure this W-division; it just happens. Note that if W = 1 for all vertices this step has no effect. This is useful for orthographic projections. The resulting geometry will be clipped to a 2x2x2 cube centered around the origin. You can think of an XY plane of this cube as the viewport of the final 2D image.
- The configurable viewport transformation (
setViewport
) will then position the viewport somewhere in the window. This step is necessary because your window is probably not a 2x2 square. The viewport transformation is configured by specifying a rectangular region of your window where you want the image to map to. The default setting for this is to fill the entire window with the viewport. If you didn't previously account for your aspect ratio then this will have the effect of squishing the scene, so you need to compensate in the vertex shader.
Rendering Points, Lines, and Triangles
The draw family (ex. drawTriangles
) of commands commissions the
rendering of a certain number of vertices worth of primitives. The
current program will get input from the current VAO, the current texture
units, and execute on all the potentially affected pixels in the current
framebuffer. Vertexes are consumed in the order they appear in their
respective source VBOs. If the VAO is missing, the program is missing, or
the current framebuffer has no color attachment, then rendering will not
work.
The drawIndexed family (ex. drawIndexedTriangles
) of commands carries
out the same effects as the non-indexed rendering commands but traverses
vertices in an order determined by the sequence of indexes packed in the
ElementArray currently bound to the element array binding target. This
mainly allows a huge reuse of vertex data in the case that the object
being rendered forms a closed mesh.
VAO
See also Graphics.GL.Low.VAO
Create a new VAO. The only thing you can do with a VAO is bind it to the vertex array binding target.
Assign the VAO to the vertex array binding target. The VAO already bound will be replaced, if any.
data VAO
A VAO stores vertex attribute layouts and the VBO source of vertices for those attributes. It also stores the state of the element array binding target. The vertex array binding target admits one VAO at a time.
Buffer Objects
See also Graphics.GL.Low.BufferObject
newVBO :: Vector Word8 -> UsageHint -> IO VBO
Create a buffer object from a blob of bytes. The usage argument hints at how often you will modify the data.
newElementArray :: Vector Word8 -> UsageHint -> IO ElementArray
Create a new ElementArray buffer object from the blob of packed indices. The usage argument hints at how often you plan to modify the data.
Bind a VBO to the array buffer binding target. The buffer object bound there will be replaced, if any.
bindElementArray :: ElementArray -> IO ()
Assign an ElementArray to the element array binding target. It will replace the ElementArray already bound there, if any. Note that the state of the element array binding target is a function of the current VAO.
updateVBO :: Vector Word8 -> Int -> IO ()
Modify the data in the currently bound VBO starting from the specified index in bytes.
updateElementArray :: Vector Word8 -> Int -> IO ()
Modify contents in the currently bound ElementArray starting at the specified index in bytes.
deleteBufferObject :: BufferObject a => a -> IO ()
Delete a VBO or ElementArray.
data VBO
A VBO is a buffer object which has vertex data. Shader programs use VBOs as input to their vertex attributes according to the configuration of the bound VAO.
data ElementArray
A buffer object which has a packed sequence of vertex indices. Indexed rendering uses the ElementArray bound to the element array binding target.
data UsageHint
Usage hint for allocation of buffer object storage.
StaticDraw | Data will seldomly change. |
DynamicDraw | Data will change. |
StreamDraw | Data will change very often. |
data IndexFormat
How indices are packed in an ElementArray buffer object.
UByteIndices | Each index is one unsigned byte. |
UShortIndices | Each index is a two byte unsigned int. |
UIntIndices | Each index is a four byte unsigned int. |
Shader Program
See also Graphics.GL.Low.Shader
Compile the code for a vertex shader and a fragment shader, then link them into a new program. If the compiler or linker fails it will throw a ProgramError.
newProgramSafe :: String -> String -> IO (Either ProgramError Program)
Same as newProgram
but does not throw exceptions.
useProgram :: Program -> IO ()
Install a program into the rendering pipeline. Replaces the program already in use, if any.
deleteProgram :: Program -> IO ()
Delete a program.
setUniform1f :: String -> [Float] -> IO ()
setUniform2f :: String -> [V2 Float] -> IO ()
setUniform3f :: String -> [V3 Float] -> IO ()
setUniform4f :: String -> [V4 Float] -> IO ()
setUniform1i :: String -> [Int] -> IO ()
setUniform2i :: String -> [V2 Int] -> IO ()
setUniform3i :: String -> [V3 Int] -> IO ()
setUniform4i :: String -> [V4 Int] -> IO ()
setUniform22 :: String -> [M22 Float] -> IO ()
setUniform33 :: String -> [M33 Float] -> IO ()
setUniform44 :: String -> [M44 Float] -> IO ()
data Program
A Program object is the combination of a compiled vertex shader and fragment shader. Programs have three kinds of inputs: vertex attributes, uniforms, and samplers. Programs have two outputs: fragment color and fragment depth. At most one program can be "in use" at a time. Same idea as binding targets it's just not called that.
data ProgramError
The error message emitted by the driver when shader compilation or linkage fails.
Vertex Attributes
See also Graphics.GL.Low.VertexAttrib
setVertexAttributeLayout :: VertexAttributeLayout -> IO ()
This configures the currently bound VAO. It calls glVertexAttribPointer and glEnableVertexAttribArray.
type VertexAttributeLayout = [LayoutElement]
The layout of interleaved vertex attribute data.
data LayoutElement
The name of a vertex input to a program combined with the component format and number of components for that attribute in the vertex data. Alternatively the size of an unused section of the data in bytes.
data ComponentFormat
The size and interpretation of a vertex attribute component. Normalized components will be mapped to floats in the range [0, 1].
VFloat | 4-byte float |
VByte | |
VUByte | |
VByteNormalized | |
VUByteNormalized | |
VShort | 2-byte signed integer |
VUShort | 2-byte unsigned integer |
VShortNormalized | |
VUShortNormalized | |
VInt | 4-byte signed integer |
VUInt | 4-byte unsigned integer |
VIntNormalized | |
VUIntNormalized |
Textures
See also Graphics.GL.Low.Texture
newTexture2D :: InternalFormat a => Vector Word8 -> Dimensions -> IO (Tex2D a)
Create a new 2D texture from a blob and its image format. Dimensions should be powers of two.
newCubeMap :: InternalFormat a => Cube (Vector Word8, Dimensions) -> IO (CubeMap a)
Create a new cube map texture from six blobs and their respective formats. Dimensions should be powers of two.
newEmptyTexture2D :: InternalFormat a => Int -> Int -> IO (Tex2D a)
Create an empty texture with the specified dimensions and format.
newEmptyCubeMap :: InternalFormat a => Int -> Int -> IO (CubeMap a)
Create a cubemap texture where each of the six sides has the specified dimensions and format.
deleteTexture :: Texture a => a -> IO ()
Delete a texture.
setActiveTextureUnit :: Enum a => a -> IO ()
Set the active texture unit. The default is zero.
bindTexture2D :: Tex2D a -> IO ()
Bind a 2D texture to the 2D texture binding target and the currently active texture unit.
bindTextureCubeMap :: CubeMap a -> IO ()
Bind a cubemap texture to the cubemap texture binding target and the currently active texture unit.
setTex2DFiltering :: Filtering -> IO ()
Set the filtering for the 2D texture currently bound to the 2D texture binding target.
setCubeMapFiltering :: Filtering -> IO ()
Set the filtering for the cubemap texture currently bound to the cubemap texture binding target.
setTex2DWrapping :: Wrapping -> IO ()
Set the wrapping mode for the 2D texture currently bound to the 2D texture binding target.
setCubeMapWrapping :: Wrapping -> IO ()
Set the wrapping mode for the cubemap texture currently bound to the cubemap texture binding target. Because no blending occurs between cube faces you probably want ClampToEdge.
data Tex2D a
A 2D texture. A program can sample a texture if it has been bound to the appropriate texture unit.
data CubeMap a
A cubemap texture is just six 2D textures. A program can sample a cubemap texture if it has been bound to the appropriate texture unit.
data Cube a
Six values, one on each side.
type Side = forall a. Cube a -> a
A type to pick one of the sides of a cube. See the accessors of the
type Cube
.
data Filtering
Texture filtering modes.
data Wrapping
Texture wrapping modes.
Repeat | Tile the texture past the boundary. |
MirroredRepeat | Tile the texture but mirror every other tile. |
ClampToEdge | Use the edge color for anything past the boundary. |
Rendering
See also Graphics.GL.Low.Render
Primitives
Draw primitives to the framebuffer currently bound to the framebuffer binding target. Each primitive drawing command takes the number of vertices in the VBOs to render. The vertices are traversed in order.
drawPoints :: Int -> IO ()
drawLineStrip :: Int -> IO ()
drawLineLoop :: Int -> IO ()
drawTriangles :: Int -> IO ()
drawTriangleStrip :: Int -> IO ()
drawTriangleFan :: Int -> IO ()
Primitives by Index
Draw primitives as above, but use the order of vertices defined in the ElementArray currently bound to the element array buffer binding target.
drawIndexedPoints :: Int -> IndexFormat -> IO ()
drawIndexedLines :: Int -> IndexFormat -> IO ()
drawIndexedLineStrip :: Int -> IndexFormat -> IO ()
drawIndexedLineLoop :: Int -> IndexFormat -> IO ()
drawIndexedTriangles :: Int -> IndexFormat -> IO ()
drawIndexedTriangleStrip :: Int -> IndexFormat -> IO ()
drawIndexedTriangleFan :: Int -> IndexFormat -> IO ()
Color Buffer
See also Graphics.GL.Low.Color
enableColorWriting :: IO ()
Allow rendering commands to modify the color buffer of the current framebuffer.
disableColorWriting :: IO ()
Disable rendering to color buffer.
clearColorBuffer :: (Float, Float, Float) -> IO ()
Clear the color buffer of the current framebuffer with the specified color. Has no effect if writing to the color buffer is disabled.
Depth Test
See also Graphics.GL.Low.Depth
enableDepthTest :: IO ()
Enable the depth test. Attempting to render pixels with a depth value greater than the depth buffer at those pixels will have no effect. Otherwise the depth in the buffer will get updated to the new pixel's depth.
disableDepthTest :: IO ()
Disable the depth test and depth buffer updates.
clearDepthBuffer :: IO ()
Clear the depth buffer with the maximum depth value.
Stencil Test
See also Graphics.GL.Low.Stencil.
enableStencil :: Stencil -> IO ()
Enable the stencil test with a set of operating parameters.
disableStencil :: IO ()
Disable the stencil test and updates to the stencil buffer, if one exists.
clearStencilBuffer :: IO ()
Clear the stencil buffer with all zeros.
In this basic configuration of the stencil, anything rendered will create a silhouette of 1s in the stencil buffer. Attempting to render a second time into the silhouette will have no effect because the stencil test will fail (ref=1 isn't greater than buffer=1).
def { func = Greater , ref = 1 , onBothPass = Replace }
data Stencil
Configuration of the stencil test and associated stencil buffer updating.
Stencil | |
|
data StencilFunc
The stencil test passes under what condition.
data StencilOp
Modification action for the stencil buffer.
Keep | Do nothing. |
Zero | Set to zero. |
Replace | Write the ref value passed to enableStencil. |
Increment | |
Decrement | |
Invert | Bitwise complement. |
IncrementWrap | |
DecrementWrap |
Scissor Test
enableScissorTest :: Viewport -> IO ()
Enable the scissor test. Graphics outside the scissor box will not be rendered.
disableScissorTest :: IO ()
Disable the scissor test.
Facet Culling
enableCulling :: Culling -> IO ()
Enable facet culling. The argument specifies whether front faces, back faces, or both will be omitted from rendering. If both front and back faces are culled you can still render points and lines.
disableCulling :: IO ()
Disable facet culling. Front and back faces will now be rendered.
Blending
See also Graphics.GL.Low.Blending.
enableBlending :: Blending -> IO ()
Enable blending with the specified blending parameters.
disableBlending :: IO ()
Disable alpha blending.
This blending configuration is suitable for ordinary alpha blending transparency effects.
Blending { sFactor = BlendSourceAlpha , dFactor = BlendOneMinusSourceAlpha , blendFunc = FuncAdd }
data Blending
Blending parameters.
Blending | |
|
data BlendFactor
Blending factors.
Viewport
data Viewport
A rectangular section of the window.
setViewport :: Viewport -> IO ()
Set the viewport. The default viewport simply covers the entire window.
Framebuffers
See also Graphics.GL.Low.Framebuffer
data DefaultFramebuffer
The default framebuffer. Bind this to render to the screen as usual.
Use the Default instance method def
to construct it.
data FBO
A framebuffer object is an alternative rendering destination. Once an FBO is bound to framebuffer binding target, it is possible to attach images (textures or RBOs) for color, depth, or stencil rendering.
bindFramebuffer :: Framebuffer a => a -> IO ()
Binds an FBO or the default framebuffer to the framebuffer binding target. Replaces the framebuffer already bound there.
Create a new framebuffer object. Before the framebuffer can be used for rendering it must have a color image attachment.
attachTex2D :: Attachable a => Tex2D a -> IO ()
Attach a 2D texture to the FBO currently bound to the framebuffer binding target.
attachCubeMap :: Attachable a => CubeMap a -> Side -> IO ()
Attach one of the sides of a cubemap texture to the FBO currently bound to the framebuffer binding target.
attachRBO :: Attachable a => RBO a -> IO ()
Attach an RBO to the FBO currently bound to the framebuffer binding target.
Renderbuffers
data RBO a
An RBO is a kind of image object used for rendering. The only thing you can do with an RBO is attach it to an FBO.
newRBO :: InternalFormat a => Int -> Int -> IO (RBO a)
Create a new renderbuffer with the specified dimensions.
Errors
data GLError
Detectable errors.
InvalidEnum | Enum argument out of range. |
InvalidValue | Integer argument out of range. |
InvalidOperation | Operation illegal in current state. |
InvalidFramebufferOperation | Framebuffer is not complete. |
OutOfMemory |
getGLError :: IO (Maybe GLError)
Check for a GL Error.
Image Formats
data Luminance
1-byte grayscale pixel format.
data LuminanceAlpha
2-byte luminance and alpha channel format.
data Depth24Stencil8
Combination depth and stencil format.
Classes
class InternalFormat a where
OpenGL internal image formats.
internalFormat :: (Eq b, Num b) => proxy a -> b
class Framebuffer a where
Framebuffers can be bound to the framebuffer binding target. There is a default framebuffer and the client may create an arbitrary number of new framebuffer objects.
framebufferName :: Num b => a -> b
class InternalFormat a => Attachable a where
The allowed attachment point for images with an internal format.
attachPoint :: (Eq b, Num b) => proxy a -> b