Castor3D  ..
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Castor3D::FrameBuffer Class Referenceabstract

Frame buffer class. More...

+ Inheritance diagram for Castor3D::FrameBuffer:
+ Collaboration diagram for Castor3D::FrameBuffer:

Public Member Functions

 DECLARE_VECTOR (FrameBufferAttachmentSPtr, Attach)
 
C3D_API FrameBuffer (Engine &p_engine)
 Constructor. More...
 
virtual C3D_API ~FrameBuffer ()
 Destructor. More...
 
C3D_API bool Initialise (Castor::Size const &p_size)
 Initialises color and depth cache buffers. More...
 
C3D_API void Cleanup ()
 Cleans up cache buffers. More...
 
C3D_API void SetClearColour (Castor::Colour const &p_colour)
 Defines the colour used when Clear is called on the color buffer. More...
 
C3D_API void Clear ()
 Clears the buffers. More...
 
C3D_API bool Bind (eFRAMEBUFFER_MODE p_mode=eFRAMEBUFFER_MODE_AUTOMATIC, eFRAMEBUFFER_TARGET p_target=eFRAMEBUFFER_TARGET_BOTH)
 Activation function, to tell the GPU it is active. More...
 
C3D_API void Unbind ()
 Deactivation function, to tell the GPU it is inactive. More...
 
C3D_API bool BlitInto (FrameBufferSPtr p_buffer, Castor::Rectangle const &p_rect, uint32_t p_components)
 Blit this frame buffer into the given one. More...
 
C3D_API bool StretchInto (FrameBufferSPtr p_buffer, Castor::Rectangle const &p_rectSrc, Castor::Rectangle const &p_rectDst, uint32_t p_components, eINTERPOLATION_MODE p_interpolation)
 Stretches this frame buffer into the given one. More...
 
C3D_API void SetDrawBuffers ()
 Specifies the buffers to be drawn into. More...
 
C3D_API void SetDrawBuffer (TextureAttachmentSPtr p_attach)
 Specifies the color buffer to be drawn into. More...
 
C3D_API void SetDrawBuffer (RenderBufferAttachmentSPtr p_attach)
 Specifies the color buffer to be drawn into. More...
 
C3D_API bool Attach (eATTACHMENT_POINT p_point, uint8_t p_index, TextureAttachmentSPtr p_texture, eTEXTURE_TARGET p_target, int p_layer=0)
 Attaches a texture to this frame buffer, at given attachment point. More...
 
C3D_API bool Attach (eATTACHMENT_POINT p_point, TextureAttachmentSPtr p_texture, eTEXTURE_TARGET p_target, int p_layer=0)
 Attaches a texture to this frame buffer, at given attachment point. More...
 
C3D_API bool Attach (eATTACHMENT_POINT p_point, uint8_t p_index, RenderBufferAttachmentSPtr p_renderBuffer)
 Attaches a render buffer to this frame buffer, at given attachment point. More...
 
C3D_API bool Attach (eATTACHMENT_POINT p_point, RenderBufferAttachmentSPtr p_renderBuffer)
 Attaches a render buffer to this frame buffer, at given attachment point. More...
 
C3D_API FrameBufferAttachmentSPtr GetAttachment (eATTACHMENT_POINT p_point, uint8_t p_index)
 Retrieves a buffer attached at given attachment point and index. More...
 
C3D_API void DetachAll ()
 Detaches all attached objects. More...
 
C3D_API void Resize (Castor::Size const &p_size)
 Resizes each attached buffer. More...
 
virtual C3D_API bool Create ()=0
 Creation function. More...
 
virtual C3D_API void Destroy ()=0
 Destruction function. More...
 
virtual C3D_API void SetDrawBuffers (AttachArray const &p_attaches)=0
 Uses given attachments to this framebuffer for next draw call. More...
 
virtual C3D_API void SetReadBuffer (eATTACHMENT_POINT p_point, uint8_t p_index)=0
 Specifies the color buffer source for pixels. More...
 
virtual C3D_API ColourRenderBufferSPtr CreateColourRenderBuffer (Castor::ePIXEL_FORMAT p_format)=0
 Creates a colour render buffer. More...
 
virtual C3D_API DepthStencilRenderBufferSPtr CreateDepthStencilRenderBuffer (Castor::ePIXEL_FORMAT p_format)=0
 Creates a depth/stencil render buffer. More...
 
virtual C3D_API RenderBufferAttachmentSPtr CreateAttachment (RenderBufferSPtr p_renderBuffer)=0
 Creates an attachment to a render buffer. More...
 
virtual C3D_API TextureAttachmentSPtr CreateAttachment (DynamicTextureSPtr p_texture)=0
 Creates an attachment to a texture. More...
 
virtual C3D_API bool IsComplete () const =0
 Checks if the FBO is complete. More...
 
virtual C3D_API bool DownloadBuffer (Castor3D::eATTACHMENT_POINT p_point, uint8_t p_index, Castor::PxBufferBaseSPtr p_buffer)=0
 Downloads the render buffer data. More...
 
Castor::Colour GetClearColour () const
 Retrieves the background colour. More...
 

Protected Member Functions

C3D_API uint32_t DoGetSamplesCount (eATTACHMENT_POINT p_point, uint8_t p_index)
 
C3D_API Castor::ePIXEL_FORMAT DoGetPixelFormat (eATTACHMENT_POINT p_point, uint8_t p_index)
 
virtual C3D_API void DoClear (uint32_t p_targets)=0
 Clears the given buffers components. More...
 
virtual C3D_API bool DoBind (eFRAMEBUFFER_TARGET p_target)=0
 Activation function, to tell the GPU it is active. More...
 
virtual C3D_API void DoUnbind ()=0
 Deactivation function, to tell the GPU it is inactive. More...
 
virtual C3D_API bool DoBlitInto (FrameBufferSPtr p_buffer, Castor::Rectangle const &p_rect, uint32_t p_components)=0
 Blit this frame buffer into the given one. More...
 
virtual C3D_API bool DoStretchInto (FrameBufferSPtr p_buffer, Castor::Rectangle const &p_rectSrc, Castor::Rectangle const &p_rectDst, uint32_t p_components, eINTERPOLATION_MODE p_interpolation)=0
 Blit this frame buffer into the given one. More...
 

Protected Attributes

AttachArray m_attaches
 All attachments. More...
 
Castor::Colour m_clearColour
 The background colour. More...
 

Detailed Description

Frame buffer class.

Author
Sylvain DOREMUS
Version
0.7.0.0
Date
12/11/2012
Remarks
A frame buffer is where a render target makes its render

Constructor & Destructor Documentation

◆ FrameBuffer()

C3D_API Castor3D::FrameBuffer::FrameBuffer ( Engine p_engine)

Constructor.

Parameters
[in]p_engineThe core engine

◆ ~FrameBuffer()

virtual C3D_API Castor3D::FrameBuffer::~FrameBuffer ( )
virtual

Destructor.

Member Function Documentation

◆ Attach() [1/4]

C3D_API bool Castor3D::FrameBuffer::Attach ( eATTACHMENT_POINT  p_point,
uint8_t  p_index,
TextureAttachmentSPtr  p_texture,
eTEXTURE_TARGET  p_target,
int  p_layer = 0 
)

Attaches a texture to this frame buffer, at given attachment point.

Parameters
[in]p_pointThe attachment point
[in]p_indexThe attachment index
[in]p_textureThe texture
[in]p_targetThe dimension to which the texture must be attached
[in]p_layerThe associated layer, if p_dimension equal eTEXTURE_TARGET_3D or eTEXTURE_TARGET_LAYER
Returns
true if OK

◆ Attach() [2/4]

C3D_API bool Castor3D::FrameBuffer::Attach ( eATTACHMENT_POINT  p_point,
TextureAttachmentSPtr  p_texture,
eTEXTURE_TARGET  p_target,
int  p_layer = 0 
)

Attaches a texture to this frame buffer, at given attachment point.

Parameters
[in]p_pointThe attachment point
[in]p_textureThe texture
[in]p_targetThe dimension to which the texture must be attached
[in]p_layerThe associated layer, if p_dimension equal eTEXTURE_TARGET_3D or eTEXTURE_TARGET_LAYER
Returns
true if OK

◆ Attach() [3/4]

C3D_API bool Castor3D::FrameBuffer::Attach ( eATTACHMENT_POINT  p_point,
uint8_t  p_index,
RenderBufferAttachmentSPtr  p_renderBuffer 
)

Attaches a render buffer to this frame buffer, at given attachment point.

Parameters
[in]p_pointThe attachment point
[in]p_indexThe attachment index
[in]p_renderBufferThe render buffer
Returns
true if OK

◆ Attach() [4/4]

C3D_API bool Castor3D::FrameBuffer::Attach ( eATTACHMENT_POINT  p_point,
RenderBufferAttachmentSPtr  p_renderBuffer 
)

Attaches a render buffer to this frame buffer, at given attachment point.

Parameters
[in]p_pointThe attachment point
[in]p_renderBufferThe render buffer
Returns
true if OK

◆ Bind()

C3D_API bool Castor3D::FrameBuffer::Bind ( eFRAMEBUFFER_MODE  p_mode = eFRAMEBUFFER_MODE_AUTOMATIC,
eFRAMEBUFFER_TARGET  p_target = eFRAMEBUFFER_TARGET_BOTH 
)

Activation function, to tell the GPU it is active.

Parameters
[in]p_targetThe frame buffer binding target
[in]p_modeThe frame buffer binding mode
Returns
true if successful

◆ BlitInto()

C3D_API bool Castor3D::FrameBuffer::BlitInto ( FrameBufferSPtr  p_buffer,
Castor::Rectangle const &  p_rect,
uint32_t  p_components 
)

Blit this frame buffer into the given one.

Parameters
[in]p_bufferThe buffer receiving this one
[in]p_rectThe rectangle
[in]p_componentsBitwise OR of eBUFFER_COMPONENT indicating which buffers are to be copied
Returns
true if successful

◆ Cleanup()

C3D_API void Castor3D::FrameBuffer::Cleanup ( )

Cleans up cache buffers.

◆ Clear()

C3D_API void Castor3D::FrameBuffer::Clear ( )

Clears the buffers.

◆ Create()

virtual C3D_API bool Castor3D::FrameBuffer::Create ( )
pure virtual

Creation function.

Returns
true if OK

◆ CreateAttachment() [1/2]

virtual C3D_API RenderBufferAttachmentSPtr Castor3D::FrameBuffer::CreateAttachment ( RenderBufferSPtr  p_renderBuffer)
pure virtual

Creates an attachment to a render buffer.

Parameters
[in]p_renderBufferThe render buffer
Returns
The created attachment

Implemented in Castor3D::BackBuffers.

◆ CreateAttachment() [2/2]

virtual C3D_API TextureAttachmentSPtr Castor3D::FrameBuffer::CreateAttachment ( DynamicTextureSPtr  p_texture)
pure virtual

Creates an attachment to a texture.

Parameters
[in]p_textureThe texture
Returns
The created attachment

Implemented in Castor3D::BackBuffers.

◆ CreateColourRenderBuffer()

virtual C3D_API ColourRenderBufferSPtr Castor3D::FrameBuffer::CreateColourRenderBuffer ( Castor::ePIXEL_FORMAT  p_format)
pure virtual

Creates a colour render buffer.

Parameters
[in]p_formatThe buffer's pixel format

◆ CreateDepthStencilRenderBuffer()

virtual C3D_API DepthStencilRenderBufferSPtr Castor3D::FrameBuffer::CreateDepthStencilRenderBuffer ( Castor::ePIXEL_FORMAT  p_format)
pure virtual

Creates a depth/stencil render buffer.

Parameters
[in]p_formatThe buffer's pixel format

◆ DECLARE_VECTOR()

Castor3D::FrameBuffer::DECLARE_VECTOR ( FrameBufferAttachmentSPtr  ,
Attach   
)

◆ Destroy()

virtual C3D_API void Castor3D::FrameBuffer::Destroy ( )
pure virtual

Destruction function.

◆ DetachAll()

C3D_API void Castor3D::FrameBuffer::DetachAll ( )

Detaches all attached objects.

◆ DoBind()

virtual C3D_API bool Castor3D::FrameBuffer::DoBind ( eFRAMEBUFFER_TARGET  p_target)
protectedpure virtual

Activation function, to tell the GPU it is active.

Parameters
[in]p_targetThe frame buffer binding target
Returns
true if successful

◆ DoBlitInto()

virtual C3D_API bool Castor3D::FrameBuffer::DoBlitInto ( FrameBufferSPtr  p_buffer,
Castor::Rectangle const &  p_rect,
uint32_t  p_components 
)
protectedpure virtual

Blit this frame buffer into the given one.

Parameters
[in]p_bufferThe buffer receiving this one
[in]p_rectThe destination rectangle
[in]p_componentsBitwise OR of eBUFFER_COMPONENT indicating which buffers are to be copied
Returns
true if successful

◆ DoClear()

virtual C3D_API void Castor3D::FrameBuffer::DoClear ( uint32_t  p_targets)
protectedpure virtual

Clears the given buffers components.

Parameters
[in]p_targetsThe buffer components, combination of eBUFFER_COMPONENT.

◆ DoGetPixelFormat()

C3D_API Castor::ePIXEL_FORMAT Castor3D::FrameBuffer::DoGetPixelFormat ( eATTACHMENT_POINT  p_point,
uint8_t  p_index 
)
protected
Parameters
[in]p_pointThe attachment point.
[in]p_indexThe attachment index.
Returns
The pixel format for attachment.

◆ DoGetSamplesCount()

C3D_API uint32_t Castor3D::FrameBuffer::DoGetSamplesCount ( eATTACHMENT_POINT  p_point,
uint8_t  p_index 
)
protected
Parameters
[in]p_pointThe attachment point.
[in]p_indexThe attachment index.
Returns
The samples count for attachment.

◆ DoStretchInto()

virtual C3D_API bool Castor3D::FrameBuffer::DoStretchInto ( FrameBufferSPtr  p_buffer,
Castor::Rectangle const &  p_rectSrc,
Castor::Rectangle const &  p_rectDst,
uint32_t  p_components,
eINTERPOLATION_MODE  p_interpolation 
)
protectedpure virtual

Blit this frame buffer into the given one.

Remarks
Interpolation for depth or stencil buffer must be eINTERPOLATION_MODE_NEAREST.
Parameters
[in]p_bufferThe buffer receiving this one.
[in]p_rectSrcThe source rectangle.
[in]p_rectDstThe destination rectangle.
[in]p_componentsBitwise OR of eBUFFER_COMPONENT indicating which buffers are to be copied.
[in]p_interpolationThe interpolation to apply if the image is stretched.
Returns
true if successful.

◆ DoUnbind()

virtual C3D_API void Castor3D::FrameBuffer::DoUnbind ( )
protectedpure virtual

Deactivation function, to tell the GPU it is inactive.

◆ DownloadBuffer()

virtual C3D_API bool Castor3D::FrameBuffer::DownloadBuffer ( Castor3D::eATTACHMENT_POINT  p_point,
uint8_t  p_index,
Castor::PxBufferBaseSPtr  p_buffer 
)
pure virtual

Downloads the render buffer data.

Parameters
[in]p_pointThe attachment point.
[in]p_indexThe attachment index.
[in]p_bufferReceives the data.

◆ GetAttachment()

C3D_API FrameBufferAttachmentSPtr Castor3D::FrameBuffer::GetAttachment ( eATTACHMENT_POINT  p_point,
uint8_t  p_index 
)

Retrieves a buffer attached at given attachment point and index.

Parameters
[in]p_pointThe attachment point.
[in]p_indexThe attachment index.
Returns
The attachment, nullptr if not found.

◆ GetClearColour()

Castor::Colour Castor3D::FrameBuffer::GetClearColour ( ) const
inline

Retrieves the background colour.

References m_clearColour.

◆ Initialise()

C3D_API bool Castor3D::FrameBuffer::Initialise ( Castor::Size const &  p_size)

Initialises color and depth cache buffers.

Parameters
[in]p_sizeThe frame buffer size.
Returns
true if OK.

◆ IsComplete()

virtual C3D_API bool Castor3D::FrameBuffer::IsComplete ( ) const
pure virtual

Checks if the FBO is complete.

Returns
false if the buffer is in error if there is an attachment missing

Implemented in Castor3D::BackBuffers.

◆ Resize()

C3D_API void Castor3D::FrameBuffer::Resize ( Castor::Size const &  p_size)

Resizes each attached buffer.

Parameters
[in]p_sizeThe new dimensions

◆ SetClearColour()

C3D_API void Castor3D::FrameBuffer::SetClearColour ( Castor::Colour const &  p_colour)

Defines the colour used when Clear is called on the color buffer.

Parameters
[in]p_colourThe colour.

◆ SetDrawBuffer() [1/2]

C3D_API void Castor3D::FrameBuffer::SetDrawBuffer ( TextureAttachmentSPtr  p_attach)

Specifies the color buffer to be drawn into.

Parameters
[in]p_attachThe color buffer

◆ SetDrawBuffer() [2/2]

C3D_API void Castor3D::FrameBuffer::SetDrawBuffer ( RenderBufferAttachmentSPtr  p_attach)

Specifies the color buffer to be drawn into.

Parameters
[in]p_attachThe color buffer

◆ SetDrawBuffers() [1/2]

C3D_API void Castor3D::FrameBuffer::SetDrawBuffers ( )

Specifies the buffers to be drawn into.

Remarks
All buffers attached are selected

◆ SetDrawBuffers() [2/2]

virtual C3D_API void Castor3D::FrameBuffer::SetDrawBuffers ( AttachArray const &  p_attaches)
pure virtual

Uses given attachments to this framebuffer for next draw call.

Parameters
[in]p_attachesThe attachments.

◆ SetReadBuffer()

virtual C3D_API void Castor3D::FrameBuffer::SetReadBuffer ( eATTACHMENT_POINT  p_point,
uint8_t  p_index 
)
pure virtual

Specifies the color buffer source for pixels.

Parameters
[in]p_pointThe color buffer
[in]p_indexThe attachment index

◆ StretchInto()

C3D_API bool Castor3D::FrameBuffer::StretchInto ( FrameBufferSPtr  p_buffer,
Castor::Rectangle const &  p_rectSrc,
Castor::Rectangle const &  p_rectDst,
uint32_t  p_components,
eINTERPOLATION_MODE  p_interpolation 
)

Stretches this frame buffer into the given one.

Remarks
Interpolation for depth or stencil buffer must be eINTERPOLATION_MODE_NEAREST.
Parameters
[in]p_bufferThe buffer receiving this one.
[in]p_rectSrcThe source rectangle.
[in]p_rectDstThe destination rectangle.
[in]p_componentsBitwise OR of eBUFFER_COMPONENT indicating which buffers are to be copied.
[in]p_interpolationThe interpolation to apply if the image is stretched.
Returns
true if successful.

◆ Unbind()

C3D_API void Castor3D::FrameBuffer::Unbind ( )

Deactivation function, to tell the GPU it is inactive.

Member Data Documentation

◆ m_attaches

AttachArray Castor3D::FrameBuffer::m_attaches
protected

All attachments.

◆ m_clearColour

Castor::Colour Castor3D::FrameBuffer::m_clearColour
protected

The background colour.

Referenced by GetClearColour().


The documentation for this class was generated from the following file: