Safe Haskell | Safe-Infered |
---|
FrameBuffer
s are 2D images in which fragments from FragmentStream
s are painted. A FrameBuffer
may contain any combination of a color buffer, a depth buffer and a stencil buffer.
FrameBuffer
s may be shown in windows, saved to memory or converted to textures.
FrameBuffer
s have no size, but takes the size of the window when shown, or are given a size when
saved to memory or converted to a texture.
- data FrameBuffer c d s
- newWindow :: String -> Vec2 Int -> Vec2 Int -> (Vec2 Int -> IO (FrameBuffer c d s)) -> (Window -> IO ()) -> IO ()
- newFrameBufferColor :: ColorFormat f => Color f Float -> FrameBuffer f () ()
- newFrameBufferColorDepth :: ColorFormat f => Color f Float -> Depth -> FrameBuffer f DepthFormat ()
- newFrameBufferColorStencil :: ColorFormat f => Color f Float -> Stencil -> FrameBuffer f () StencilFormat
- newFrameBufferColorDepthStencil :: ColorFormat f => Color f Float -> Depth -> Stencil -> FrameBuffer f DepthFormat StencilFormat
- newFrameBufferDepth :: Depth -> FrameBuffer () DepthFormat ()
- newFrameBufferStencil :: Stencil -> FrameBuffer () () StencilFormat
- newFrameBufferDepthStencil :: Depth -> Stencil -> FrameBuffer () DepthFormat StencilFormat
- getFrameBufferColor :: forall c d s a. GPUFormat c => CPUFormat c -> Vec2 Int -> FrameBuffer c d s -> Ptr a -> IO ()
- getFrameBufferDepth :: CPUFormat DepthFormat -> Vec2 Int -> FrameBuffer c DepthFormat s -> Ptr a -> IO ()
- getFrameBufferStencil :: CPUFormat StencilFormat -> Vec2 Int -> FrameBuffer c d StencilFormat -> Ptr a -> IO ()
- getFrameBufferCPUFormatByteSize :: StorableCPUFormat f => f -> Vec2 Int -> Int
- paintColor :: ColorFormat c => Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c d s -> FrameBuffer c d s
- paintDepth :: DepthFunction -> DepthMask -> FragmentStream FragmentDepth -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat s
- paintColorDepth :: ColorFormat c => DepthFunction -> DepthMask -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float), FragmentDepth) -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat s
- paintStencil :: StencilTests -> StencilOps -> StencilOps -> FragmentStream (Fragment a) -> FrameBuffer c d StencilFormat -> FrameBuffer c d StencilFormat
- paintDepthStencil :: StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> FragmentStream FragmentDepth -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormat
- paintColorStencil :: ColorFormat c => StencilTests -> StencilOps -> StencilOps -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c d StencilFormat -> FrameBuffer c d StencilFormat
- paintColorDepthStencil :: ColorFormat c => StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float), FragmentDepth) -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormat
- paintRastDepth :: DepthFunction -> DepthMask -> FragmentStream (Fragment a) -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat s
- paintColorRastDepth :: ColorFormat c => DepthFunction -> DepthMask -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat s
- paintRastDepthStencil :: StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> FragmentStream (Fragment a) -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormat
- paintColorRastDepthStencil :: ColorFormat c => StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormat
- type ColorMask f = Color f Bool
- data Blending
- data BlendEquation
- = FuncAdd
- | FuncSubtract
- | FuncReverseSubtract
- | Min
- | Max
- | LogicOp
- data BlendingFactor
- data LogicOp
- = Clear
- | And
- | AndReverse
- | Copy
- | AndInverted
- | Noop
- | Xor
- | Or
- | Nor
- | Equiv
- | Invert
- | OrReverse
- | CopyInverted
- | OrInverted
- | Nand
- | Set
- data ComparisonFunction
- type DepthFunction = ComparisonFunction
- type DepthMask = Bool
- data StencilOps = StencilOps {}
- data StencilOp
- = OpZero
- | OpKeep
- | OpReplace
- | OpIncr
- | OpIncrWrap
- | OpDecr
- | OpDecrWrap
- | OpInvert
- data StencilTest = StencilTest {}
- data StencilTests = StencilTests StencilTest StencilTest
- type FragmentDepth = Fragment Float
The data type
data FrameBuffer c d s Source
A polymorphic frame buffer. It is parameterized on the type of color buffer, depth buffer and stencil buffer.
Any instances of ColorFormat
can be used for color buffer, or '()' to denote no color buffer.
For depth and stencil buffers, DepthFormat
and StencilFormat
marks the existance of buffer, while '()'
marks the inexistance.
Displaying framebuffers
:: String | The window title |
-> Vec2 Int | The window position |
-> Vec2 Int | The window size |
-> (Vec2 Int -> IO (FrameBuffer c d s)) | This function is evaluated every time the window needs to be redrawn, and the resulting |
-> (Window -> IO ()) | Extra optional initialization of the window. The provided |
-> IO () |
Cretes and shows a new GPipe window. Use the last parameter to add extra GLUT callbacks to the window. Note that you can't register your own displayCallback
and reshapeCallback
.
Creation
These functions create new FrameBuffer
s with initial color, depth values and/or stencil values.
newFrameBufferColor :: ColorFormat f => Color f Float -> FrameBuffer f () ()Source
newFrameBufferColorDepth :: ColorFormat f => Color f Float -> Depth -> FrameBuffer f DepthFormat ()Source
newFrameBufferColorStencil :: ColorFormat f => Color f Float -> Stencil -> FrameBuffer f () StencilFormatSource
newFrameBufferColorDepthStencil :: ColorFormat f => Color f Float -> Depth -> Stencil -> FrameBuffer f DepthFormat StencilFormatSource
Data retrieval
These functions provides the means for saving a FrameBuffer
to main memory without the need to
show it in a window.
:: forall c d s a . GPUFormat c | |
=> CPUFormat c | The format to store data to |
-> Vec2 Int | The size to give the frame buffer |
-> FrameBuffer c d s | A frame buffer with a color buffer |
-> Ptr a | A pointer to the memory where the data will be saved |
-> IO () |
Saves a FrameBuffer
s color buffer to main memory.
:: CPUFormat DepthFormat | The format to store data to |
-> Vec2 Int | The size to give the frame buffer |
-> FrameBuffer c DepthFormat s | A frame buffer with a depth buffer |
-> Ptr a | A pointer to the memory where the data will be saved |
-> IO () |
Saves a FrameBuffer
s depth buffer to main memory.
:: CPUFormat StencilFormat | The format to store data to |
-> Vec2 Int | The size to give the frame buffer |
-> FrameBuffer c d StencilFormat | A frame buffer with a stencil buffer |
-> Ptr a | A pointer to the memory where the data will be saved |
-> IO () |
Saves a FrameBuffer
s stencil buffer to main memory.
getFrameBufferCPUFormatByteSizeSource
:: StorableCPUFormat f | |
=> f | The format to store data to |
-> Vec2 Int | The size to give the frame buffer |
-> Int | The size in bytes of the data |
Returns the byte size needed to store a certain format and size of a framebuffer. Use this to
allocate memory before using getFrameBufferColor
, getFrameBufferDepth
or getFrameBufferStencil
.
Paint operations
These functions paint FragmentStream
s on FrameBuffer
s. A lot of different functions are
provided for different types of FrameBuffer
s and FragmentStream
s, all which takes more or less
state values. The preffered way of using those is to curry them into the specific functions you need
in your GPipe program, e.g.
paintSolid =
paintColorRastDepth
Lequal
True
NoBlending
(RGB (vec
True
))
The RastDepth
-functions uses the rasterized depth for the fragments.
Functions with two StencilOps
arguments use them in this order: First if stencil test fail, second if stencil test pass.
Functions with three StencilOps
arguments use them in this order: First if stencil test fail, second if depth test fail, third if depth test pass.
paintColor :: ColorFormat c => Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c d s -> FrameBuffer c d sSource
paintDepth :: DepthFunction -> DepthMask -> FragmentStream FragmentDepth -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat sSource
paintColorDepth :: ColorFormat c => DepthFunction -> DepthMask -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float), FragmentDepth) -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat sSource
paintStencil :: StencilTests -> StencilOps -> StencilOps -> FragmentStream (Fragment a) -> FrameBuffer c d StencilFormat -> FrameBuffer c d StencilFormatSource
paintDepthStencil :: StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> FragmentStream FragmentDepth -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormatSource
paintColorStencil :: ColorFormat c => StencilTests -> StencilOps -> StencilOps -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c d StencilFormat -> FrameBuffer c d StencilFormatSource
paintColorDepthStencil :: ColorFormat c => StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float), FragmentDepth) -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormatSource
paintRastDepth :: DepthFunction -> DepthMask -> FragmentStream (Fragment a) -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat sSource
paintColorRastDepth :: ColorFormat c => DepthFunction -> DepthMask -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c DepthFormat s -> FrameBuffer c DepthFormat sSource
paintRastDepthStencil :: StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> FragmentStream (Fragment a) -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormatSource
paintColorRastDepthStencil :: ColorFormat c => StencilTests -> StencilOps -> DepthFunction -> DepthMask -> StencilOps -> StencilOps -> Blending -> ColorMask c -> FragmentStream (Color c (Fragment Float)) -> FrameBuffer c DepthFormat StencilFormat -> FrameBuffer c DepthFormat StencilFormatSource
type ColorMask f = Color f BoolSource
True
for each color component that should be written to the FrameBuffer
.
Sets how the painted colors are blended with the FrameBuffer
s previous value.
NoBlending | The painted fragment completely overwrites the previous value. |
Blend (BlendEquation, BlendEquation) ((BlendingFactor, BlendingFactor), (BlendingFactor, BlendingFactor)) (Color RGBAFormat Float) | Use blending equations to combine the fragment with the previous value.
The first |
BlendLogicOp LogicOp | Use a |
data BlendEquation
data BlendingFactor
data LogicOp
data ComparisonFunction
type DepthFunction = ComparisonFunctionSource
The function used to compare the fragment's depth and the depth buffers depth with.
True
if the depth component should be written to the FrameBuffer
.
data StencilOps Source
Sets the operations that should be performed on the FrameBuffer
s stencil value
StencilOps | |
|
data StencilOp
data StencilTest Source
Sets a test that should be performed on the stencil value.
StencilTest | |
|
data StencilTests Source
Sets the tests that should be performed on the stencil value, first for front facing triangles and other primitives, then for back facing triangles.
type FragmentDepth = Fragment FloatSource