caramia-0.7.2.2: High-level OpenGL bindings

Safe HaskellNone
LanguageHaskell2010

Graphics.Caramia.Framebuffer

Contents

Description

Framebuffers. You can render on them.

If you come from the OpenGL world, for simplicity, we have combined the concept of draw buffers and color attachments. Nth color attachment is bound exactly to Nth draw buffer. Caramia only talks about draw buffers.

https://www.opengl.org/wiki/Framebuffer_Object

Either OpenGL 3.0 or GL_ARB_framebuffer_object is required for this module.

Synopsis

Creating framebuffers

newFramebuffer :: MonadIO m => [(Attachment, TextureTarget)] -> m Framebuffer Source

Creates a new framebuffer.

Specifying texture targets

frontTextureTarget :: Texture -> TextureTarget Source

Make a texture target that is the "front" of the given texture.

This is the most common use case. "front" means the first texture in a texture array and the base layer mipmap level.

mipmapTextureTarget Source

Arguments

:: Texture 
-> Int

Which mipmap layer?

-> TextureTarget 

Map a specific mipmlayer from a texture.

layerTextureTarget Source

Arguments

:: Texture 
-> Int

Which mipmap layer?

-> Int

Which topological layer?

-> TextureTarget 

Map a specific mipmap layer of a specific layer in a 3D or array texture.

Size query

getDimensions :: MonadIO m => Framebuffer -> m (Int, Int) Source

Returns the size of a framebuffer.

This is an IO action because it can change for the screen framebuffer.

Clearing framebuffers

clear :: MonadIO m => Clearing -> Framebuffer -> m () Source

Clears values in a framebuffer.

data Clearing Source

Specifies what to clear in a clear invocation.

Use clearing smart constructor instead for forward-compatibility.

Each member of this data type is a Maybe value; if any value is Just then that value is cleared, otherwise it is not touched.

Constructors

Clearing 

Fields

clearDepth :: !(Maybe Float)

Clear depth buffer to this value.

clearStencil :: !(Maybe Int32)

Clear stencil buffer to this value.

clearColor :: !(Maybe Color)

Clear (all) color buffers to some color.

clearing :: Clearing Source

Smart constructor for Clearing. All members are Nothing.

Special framebuffers

screenFramebuffer :: Framebuffer Source

Returns the screen framebuffer.

Note that all screenFramebuffers are equal to each other with Eq, even those in unrelated Caramia contexts.

This makes it easy to check if any framebuffer happens to be the screen framebuffer.

Hardware limits

getMaximumDrawBuffers :: MonadIO m => m Int Source

Returns the maximum number of draw buffers in the current context.

Almost all GPUs in the last few years have at least 8.

Views