Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | List of all members
om::graphics::textures::Framebuffer Class Reference

A class that enables render-to-texture by specifying textures and their attachment points. More...

#include <omGraphicsFramebuffer.h>

Inheritance diagram for om::graphics::textures::Framebuffer:
om::graphics::devices::GraphicsContextObject

Public Member Functions

 Framebuffer ()
 Create a default framebuffer with no attachments. More...
 
 Framebuffer (devices::GraphicsContext *context)
 Create a default GPU framebuffer for the specified context with no attachments. More...
 
Size getTargetCount () const
 Return the total number of attached target textures for this framebuffer. More...
 
Size getTargetCount (FramebufferAttachment::Type attachmentType) const
 Return the total number of attached target textures with the specified attachment type for this framebuffer. More...
 
TexturegetTarget (const FramebufferAttachment &attachment) const
 Return the texture that is attached at the specified framebuffer attachment point. More...
 
Bool hasTarget (const FramebufferAttachment &attachment) const
 Return whether or not this framebuffer has a valid texture attached to the specified attachment point. More...
 
Bool setTarget (const FramebufferAttachment &attachment, Texture *newTarget, TextureFace face=TextureFace::FRONT)
 Set the target texture for the specified framebuffer attachment point. More...
 
Bool removeTarget (const FramebufferAttachment &attachment)
 Remove any previously attached texture from the specified framebuffer attachment point. More...
 
void removeTargets (FramebufferAttachment::Type attachmentType)
 Remove all attached target textures with the specified attachment type from this framebuffer. More...
 
void clearTargets ()
 Remove all attached target textures from this framebuffer. More...
 
TextureFace getTargetFace (const FramebufferAttachment &attachment)
 Return an object representing which face of the texture at the specified attachment point is being used. More...
 
Bool setTargetFace (const FramebufferAttachment &attachment, TextureFace newFace)
 Set the face of the texture at the specified attachment point that is being used. More...
 
Size getWidth () const
 Return the minimum size of the framebuffer in pixels along the X direction. More...
 
Size getHeight () const
 Return the minimum size of the framebuffer in pixels along the Y direction. More...
 
Size getSize (Index dimension) const
 Return the minimum size of the framebuffer in pixels along the specified dimension index. More...
 
Size getMinimumSize (Index dimension) const
 Return the minimum size of the framebuffer in pixels along the specified dimension index. More...
 
Size getMaximumSize (Index dimension) const
 Return the maximum size of the framebuffer in pixels along the specified dimension index. More...
 
AABB2f getViewport () const
 Return a 2D AABB object that covers the rectangular screen area shared by all target textures. More...
 
virtual void setContext (devices::GraphicsContext *newContext)
 Set a pointer to the graphics context this buffer should use to do rendering. More...
 
virtual void upload (UploadRequest &request)
 Upload this framebuffer's CPU representation to the GPU device. More...
 
virtual void download (DownloadRequest &request)
 Download the framebuffer's GPU representation to CPU memory. More...
 
virtual Bool isUploaded () const
 Return whether or not this framebuffer has been successfully created and uploaded to the device. More...
 
virtual Bool isDownloaded () const
 Return whether or not this framebuffer has a copy of its data stored in CPU-side memory. More...
 
virtual Bool isValid () const
 Return whether or not the framebuffer is valid and can be used as a render target. More...
 
const DeviceFramebuffergetRenderable () const
 Return a pointer to the context-renderable texture for this texture, or NULL if there is none. More...
 
- Public Member Functions inherited from om::graphics::devices::GraphicsContextObject
virtual ~GraphicsContextObject ()
 Destory this graphics context object. More...
 
GraphicsContextgetContext () const
 Return a pointer to the graphics context this context object is using to do rendering. More...
 
void clearContext ()
 Clear the previous context from this object. More...
 
void upload ()
 Upload this resource's CPU representation to the GPU device. More...
 
void download ()
 Upload this resource's CPU representation to the GPU device. More...
 

Additional Inherited Members

- Protected Member Functions inherited from om::graphics::devices::GraphicsContextObject
 GraphicsContextObject ()
 Create a new graphics context object that doesn't have an associated graphics context. More...
 
 GraphicsContextObject (GraphicsContext *newContext)
 Create a new graphics context object that uses the specified context for rendering. More...
 
- Protected Attributes inherited from om::graphics::devices::GraphicsContextObject
GraphicsContextcontext
 A pointer to the graphics context this object is using. More...
 

Detailed Description

A class that enables render-to-texture by specifying textures and their attachment points.

A Framebuffer object contains a set of associations between rendering framebuffer attachment points and textures which are to be used for render-to-texture. This framebuffer object can then be used as a render target, where the output of rendering will be sent to the texture targets specified here rather than the main screen.

Constructor & Destructor Documentation

om::graphics::textures::Framebuffer::Framebuffer ( )

Create a default framebuffer with no attachments.

om::graphics::textures::Framebuffer::Framebuffer ( devices::GraphicsContext context)

Create a default GPU framebuffer for the specified context with no attachments.

Member Function Documentation

Size om::graphics::textures::Framebuffer::getTargetCount ( ) const
inline

Return the total number of attached target textures for this framebuffer.

Size om::graphics::textures::Framebuffer::getTargetCount ( FramebufferAttachment::Type  attachmentType) const

Return the total number of attached target textures with the specified attachment type for this framebuffer.

Texture* om::graphics::textures::Framebuffer::getTarget ( const FramebufferAttachment attachment) const

Return the texture that is attached at the specified framebuffer attachment point.

If there is no target texture for that attachment point, a NULL texture resource is returned.

Bool om::graphics::textures::Framebuffer::hasTarget ( const FramebufferAttachment attachment) const

Return whether or not this framebuffer has a valid texture attached to the specified attachment point.

Bool om::graphics::textures::Framebuffer::setTarget ( const FramebufferAttachment attachment,
Texture newTarget,
TextureFace  face = TextureFace::FRONT 
)

Set the target texture for the specified framebuffer attachment point.

If the specified Texture is valid and supports the specified texture face, and if the specified attachment point is supported and valid, the texture is used as the target for the specified attachment point and TRUE is returned indicating success. Otherwise, FALSE is returned indicating failure, leaving the framebuffer unchanged.

Bool om::graphics::textures::Framebuffer::removeTarget ( const FramebufferAttachment attachment)

Remove any previously attached texture from the specified framebuffer attachment point.

If a texture was successfully removed, TRUE is returned. Otherwise, FALSE is returned, indicating that no texture target was removed.

void om::graphics::textures::Framebuffer::removeTargets ( FramebufferAttachment::Type  attachmentType)

Remove all attached target textures with the specified attachment type from this framebuffer.

void om::graphics::textures::Framebuffer::clearTargets ( )

Remove all attached target textures from this framebuffer.

TextureFace om::graphics::textures::Framebuffer::getTargetFace ( const FramebufferAttachment attachment)

Return an object representing which face of the texture at the specified attachment point is being used.

If there is no texture at that attachment point, and UNDEFINED texture face is returned. Otherwise, the texture face that is being used is returned. This will be FRONT, unless the texture is a cube map.

Bool om::graphics::textures::Framebuffer::setTargetFace ( const FramebufferAttachment attachment,
TextureFace  newFace 
)

Set the face of the texture at the specified attachment point that is being used.

If there is no texture at that attachment point or if the attached texture doesn't support the specified face type, FALSE is returned and the target face is not changed. Otherwise, the framebuffer uses the specified texture face for the attachment point and returns TRUE.

Size om::graphics::textures::Framebuffer::getWidth ( ) const
inline

Return the minimum size of the framebuffer in pixels along the X direction.

This method finds the smallest size of the attached textures along the X direction.

If there are no attached textures, 0 is returned.

Size om::graphics::textures::Framebuffer::getHeight ( ) const
inline

Return the minimum size of the framebuffer in pixels along the Y direction.

This method finds the smallest size of the attached textures along the Y direction.

If there are no attached textures, 0 is returned.

Size om::graphics::textures::Framebuffer::getSize ( Index  dimension) const
inline

Return the minimum size of the framebuffer in pixels along the specified dimension index.

This method finds the smallest size of the attached textures along the given dimension. Indices start from 0 and count to d-1 for a framebuffer with d dimensions. Since framebuffers are almost always 1D or 2D, dimension indices greater than 1 will result in a size of 1 being returned, since even a 1x1 framebuffer has a 3D depth of 1 pixel.

If there are no attached textures, 0 is returned.

Size om::graphics::textures::Framebuffer::getMinimumSize ( Index  dimension) const

Return the minimum size of the framebuffer in pixels along the specified dimension index.

This method finds the smallest size of the attached textures along the given dimension. Indices start from 0 and count to d-1 for a framebuffer with d dimensions. Since framebuffers are almost always 1D or 2D, dimension indices greater than 1 will result in a size of 1 being returned, since even a 1x1 framebuffer has a 3D depth of 1 pixel.

If there are no attached textures, 0 is returned.

Size om::graphics::textures::Framebuffer::getMaximumSize ( Index  dimension) const

Return the maximum size of the framebuffer in pixels along the specified dimension index.

This method finds the largest size of the attached textures along the given dimension. Indices start from 0 and count to d-1 for a framebuffer with d dimensions. Since framebuffers are almost always 1D or 2D, dimension indices greater than 1 will result in a size of 1 being returned, since even a 1x1 framebuffer has a 3D depth of 1 pixel.

If there are no attached textures, 0 is returned.

AABB2f om::graphics::textures::Framebuffer::getViewport ( ) const

Return a 2D AABB object that covers the rectangular screen area shared by all target textures.

If some of the target textures have different sizes, it uses the smallest size, starting the lower left corner of all textures, where all textures have texels.

virtual void om::graphics::textures::Framebuffer::setContext ( devices::GraphicsContext newContext)
virtual

Set a pointer to the graphics context this buffer should use to do rendering.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual void om::graphics::textures::Framebuffer::upload ( UploadRequest request)
virtual

Upload this framebuffer's CPU representation to the GPU device.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual void om::graphics::textures::Framebuffer::download ( DownloadRequest request)
virtual

Download the framebuffer's GPU representation to CPU memory.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual Bool om::graphics::textures::Framebuffer::isUploaded ( ) const
virtual

Return whether or not this framebuffer has been successfully created and uploaded to the device.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual Bool om::graphics::textures::Framebuffer::isDownloaded ( ) const
virtual

Return whether or not this framebuffer has a copy of its data stored in CPU-side memory.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual Bool om::graphics::textures::Framebuffer::isValid ( ) const
virtual

Return whether or not the framebuffer is valid and can be used as a render target.

A framebuffer may not be valid if it has no target textures, has an incomplete set of target textures (missing a required attachment), or if some of the target textures have an unsupported format.

Reimplemented from om::graphics::devices::GraphicsContextObject.

const DeviceFramebuffer* om::graphics::textures::Framebuffer::getRenderable ( ) const
inline

Return a pointer to the context-renderable texture for this texture, or NULL if there is none.

If the texture has a valid context and the the images for this texture have been uploaded to the GPU successfully after a call to upload(), the method returns a pointer to the GPU texture instance for this texture object.

Otherwise, the texture is not renderable and NULL is returned.


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