Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- newFramebuffer :: [(Attachment, TextureTarget)] -> IO Framebuffer
- data Framebuffer
- frontTextureTarget :: Texture -> TextureTarget
- mipmapTextureTarget :: Texture -> Int -> TextureTarget
- layerTextureTarget :: Texture -> Int -> Int -> TextureTarget
- data TextureTarget
- data Attachment
- getDimensions :: Framebuffer -> IO (Int, Int)
- clear :: Clearing -> Framebuffer -> IO ()
- data Clearing = Clearing {
- clearDepth :: !(Maybe Float)
- clearStencil :: !(Maybe Int32)
- clearColor :: !(Maybe Color)
- clearing :: Clearing
- screenFramebuffer :: Framebuffer
- getMaximumDrawBuffers :: IO Int
- viewTargets :: Framebuffer -> [(Attachment, TextureTarget)]
Creating framebuffers
newFramebuffer :: [(Attachment, TextureTarget)] -> IO 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.
:: Texture | |
-> Int | Which mipmap layer? |
-> TextureTarget |
Map a specific mipmlayer from a texture.
:: 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.
data TextureTarget Source
data Attachment Source
Size query
getDimensions :: Framebuffer -> IO (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 :: Clearing -> Framebuffer -> IO () Source
Clears values in a framebuffer.
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.
Clearing | |
|
Special framebuffers
screenFramebuffer :: Framebuffer Source
Returns the screen framebuffer.
Note that all screenFramebuffer
s 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 :: IO 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
viewTargets :: Framebuffer -> [(Attachment, TextureTarget)] Source