All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Luminous::FrameBuffer Class Reference

This class is an abstraction of a generic render target. More...

#include <Luminous/FrameBuffer.hpp>

Inheritance diagram for Luminous::FrameBuffer:
Luminous::RenderResource Patterns::NotCopyable

Public Types

enum  FrameBufferBind { BIND_DEFAULT, BIND_READ, BIND_DRAW }
 How FrameBuffer is bound. Determines what to do when target is bound. More...
 
enum  FrameBufferType { INVALID, WINDOW, NORMAL }
 Type of FrameBuffer. More...
 
- Public Types inherited from Luminous::RenderResource
typedef uint64_t Id
 Id of a resource.
 
enum  Type {
  VertexArray, Buffer, Program, Texture,
  RenderBuffer, FrameBuffer
}
 Different types of render resources. More...
 

Public Member Functions

void attach (GLenum attachment, Luminous::Texture &texture)
 Attach a Texture to this render target. More...
 
void attach (GLenum attachment, Luminous::RenderBuffer &buffer)
 Attach a RenderBuffer to this render target. More...
 
Luminous::RenderBuffercreateRenderBufferAttachment (GLenum attachment, GLenum storageFormat)
 Creates RenderBuffer and attaches it to given slot. More...
 
Luminous::TexturecreateTextureAttachment (GLenum attachment, const Luminous::PixelFormat &format)
 Creates Texture and attaches it to given slot. More...
 
FrameBufferCopy deepCopy () const
 Deep copy creates an identical render target to the copied one. More...
 
 FrameBuffer (FrameBufferType type=NORMAL)
 Constructor of FrameBuffer. More...
 
 FrameBuffer (const FrameBufferCopy &rt)
 Construct render target from proxy object returned by one of copy functions. More...
 
 FrameBuffer (FrameBuffer &&rt)
 Move constructor. More...
 
FrameBufferoperator= (const FrameBufferCopy &rt)
 Assign proxy object to render target. More...
 
FrameBufferoperator= (FrameBuffer &&rt)
 Move assignment operator. More...
 
Luminous::RenderBufferrenderBuffer (GLenum attachment) const
 Returns RenderBuffer attached for given slot. More...
 
QList< GLenum > renderBufferAttachments () const
 Returns list of attachments where RenderBuffer is used. More...
 
unsigned samples () const
 Number of samples if using multisampling. More...
 
void setSamples (unsigned int samples)
 Sets number of samples for multisampling. More...
 
void setSize (const Nimble::Size &size)
 Sets size for this render target. More...
 
void setTargetBind (FrameBufferBind bind)
 Sets the binding type for this target. More...
 
FrameBufferCopy shallowCopy () const
 Shallow copy with attachments. More...
 
FrameBufferCopy shallowCopyNoAttachments () const
 Shallow copy without attachments. More...
 
const Nimble::Sizesize () const
 Size of the render target. More...
 
FrameBufferBind targetBind () const
 Returns the current binding type for this target. More...
 
FrameBufferType targetType () const
 Returns type of this render target. More...
 
Luminous::Texturetexture (GLenum attachment) const
 Returns Texture attached for given slot. More...
 
QList< GLenum > textureAttachments () const
 Returns list of attachments where Texture is used. More...
 
 ~FrameBuffer ()
 Destructor.
 
- Public Member Functions inherited from Luminous::RenderResource
unsigned int expiration () const
 Returns resource expiration time. More...
 
int generation () const
 Returns generation of this resource. More...
 
void invalidate ()
 Invalidates correspondent GPU objects and forces uploading of data to GPU.
 
RenderResourceoperator= (RenderResource &&rr)
 Move assignment operator. More...
 
 RenderResource (Type type)
 Constructor of RenderResource. More...
 
 RenderResource (RenderResource &&rr)
 Move constructor. More...
 
Id resourceId () const
 Returns identifier of resource. More...
 
Type resourceType () const
 Returns type of the resource. More...
 
void setExpiration (unsigned int seconds)
 Set resource expiration time. More...
 
void setGeneration (int generation)
 Sets generation for this resource. More...
 
virtual ~RenderResource ()
 Destructor of RenderResource.
 

Additional Inherited Members

- Protected Member Functions inherited from Luminous::RenderResource
RenderResourceoperator= (const RenderResource &rr)
 Assignment operator. More...
 
 RenderResource (const RenderResource &rr)
 Copy constructor. More...
 

Detailed Description

This class is an abstraction of a generic render target.

It provides an abstraction of the OpenGL FrameBufferObject API. GPU correspondent of this class is FrameBufferGL.

Member Enumeration Documentation

How FrameBuffer is bound. Determines what to do when target is bound.

Enumerator
BIND_DEFAULT 

Bind into both read and draw targets.

BIND_READ 

Bind only for read target.

BIND_DRAW 

Bind only for draw target.

Type of FrameBuffer.

Enumerator
INVALID 

Invalid is used in case of error.

WINDOW 

This object represents back buffer of window.

NORMAL 

This render target has textures or manually allocated render buffers as its target buffers.

Constructor & Destructor Documentation

Luminous::FrameBuffer::FrameBuffer ( FrameBufferType  type = NORMAL)

Constructor of FrameBuffer.

Parameters
typeType of the render target
Luminous::FrameBuffer::FrameBuffer ( const FrameBufferCopy &  rt)

Construct render target from proxy object returned by one of copy functions.

See Also
shallowCopyNoAttachments, shallowCopy, deepCopy
Parameters
rtFrameBufferCopy of the copied render target
Luminous::FrameBuffer::FrameBuffer ( FrameBuffer &&  rt)

Move constructor.

Parameters
rtRender target to move

Member Function Documentation

void Luminous::FrameBuffer::attach ( GLenum  attachment,
Luminous::Texture texture 
)

Attach a Texture to this render target.

Parameters
attachmentAttachment point (f. ex. GL_COLOR_ATTACHMENT0)
textureTexture for attachment
void Luminous::FrameBuffer::attach ( GLenum  attachment,
Luminous::RenderBuffer buffer 
)

Attach a RenderBuffer to this render target.

Parameters
attachmentAttachment point (f. ex. GL_COLOR_ATTACHMENT0)
bufferRenderBuffer to attach
Luminous::RenderBuffer& Luminous::FrameBuffer::createRenderBufferAttachment ( GLenum  attachment,
GLenum  storageFormat 
)

Creates RenderBuffer and attaches it to given slot.

Parameters
attachmentSlot to attach newly created render buffer
storageFormatFormat of the render buffer to be created
Returns
Reference to the created render buffer
Luminous::Texture& Luminous::FrameBuffer::createTextureAttachment ( GLenum  attachment,
const Luminous::PixelFormat format 
)

Creates Texture and attaches it to given slot.

Parameters
attachmentSlot to attach newly created texture
formatFormat of the texture to be created
Returns
Reference to the created texture
FrameBufferCopy Luminous::FrameBuffer::deepCopy ( ) const

Deep copy creates an identical render target to the copied one.

Copied object has its own attachments whose values are copied from this.

Returns
Proxy object for constructing new FrameBuffer
FrameBuffer& Luminous::FrameBuffer::operator= ( const FrameBufferCopy &  rt)

Assign proxy object to render target.

See Also
shallowCopyNoAttachments, shallowCopy, deepCopy
Parameters
rtFrameBufferCopy of the copied render target
Returns
Reference to this
FrameBuffer& Luminous::FrameBuffer::operator= ( FrameBuffer &&  rt)

Move assignment operator.

Parameters
rtFrameBuffer to move
Returns
Reference to this
Luminous::RenderBuffer* Luminous::FrameBuffer::renderBuffer ( GLenum  attachment) const

Returns RenderBuffer attached for given slot.

If no render buffer is attached here returns nullptr.

Parameters
attachmentAttachment slot to be searched.
Returns
Pointer to the attachment. If none found nullptr is returned.
QList<GLenum> Luminous::FrameBuffer::renderBufferAttachments ( ) const

Returns list of attachments where RenderBuffer is used.

Returns
Enumerations for render buffer attachments
unsigned Luminous::FrameBuffer::samples ( ) const

Number of samples if using multisampling.

Zero if multisampling is disabled.

See Also
setSamples
Returns
Number of samples
void Luminous::FrameBuffer::setSamples ( unsigned int  samples)

Sets number of samples for multisampling.

Zero disables multisampling

Parameters
samplesNumber of samples to take
See Also
samples
void Luminous::FrameBuffer::setSize ( const Nimble::Size size)

Sets size for this render target.

See Also
size
Parameters
sizeSize for attachments
void Luminous::FrameBuffer::setTargetBind ( FrameBufferBind  bind)

Sets the binding type for this target.

Parameters
bindHow to bind this target.
See Also
bind
FrameBufferCopy Luminous::FrameBuffer::shallowCopy ( ) const

Shallow copy with attachments.

The copied FrameBuffer will use the same render buffers and textures as attachments.

Returns
Proxy object for constructing new FrameBuffer
FrameBufferCopy Luminous::FrameBuffer::shallowCopyNoAttachments ( ) const

Shallow copy without attachments.

Copes only target type, size and sampling options.

Returns
Proxy object for constructing new FrameBuffer
const Nimble::Size& Luminous::FrameBuffer::size ( ) const

Size of the render target.

Each attachment has this as theirs size

See Also
setSize
Returns
Size of the target
FrameBufferBind Luminous::FrameBuffer::targetBind ( ) const

Returns the current binding type for this target.

See Also
setTargetBind
Returns
How to bind this target.
FrameBufferType Luminous::FrameBuffer::targetType ( ) const

Returns type of this render target.

Returns
Type of this target.
Luminous::Texture* Luminous::FrameBuffer::texture ( GLenum  attachment) const

Returns Texture attached for given slot.

If no texture is attached here returns nullptr.

Parameters
attachmentAttachment slot to be searched.
Returns
Pointer to the attachment. If none found nullptr is returned.
QList<GLenum> Luminous::FrameBuffer::textureAttachments ( ) const

Returns list of attachments where Texture is used.

Returns
Enumerations textures attached