Classes | Private Member Functions | Private Attributes

VR3FBO Class Reference

The FBO class. More...

#include <VR3FBO.h>

Collaboration diagram for VR3FBO:
Collaboration graph
[legend]

List of all members.

Classes

struct  ArrayElement
 An element in the images array. More...

Public Member Functions

Constructor and Destructor
 VR3FBO (GLsizei width, GLsizei height)
 Constructor of the class.
 ~VR3FBO ()
 Destructor of the class.
Start and Stop Functions
void Start ()
 Activates the Framebuffer Object.
Images Management Functions
void AddImage (int attachpoint, GLint internalformat, GLenum format, GLenum type)
 Adds a new texture image to an attachment point.
void ActivateTexture (int attachpoint, unsigned int unit_id)
 Activates a texture image on a specified texture unit.
void SetFiltering (int attachpoint, GLint min_filter, GLint mag_filter)
 Activates a texture image on a specified texture unit.

Private Member Functions

 VR3FBO (const VR3FBO &)
 Disable default copy constructor.
VR3FBOoperator= (const VR3FBO &)
 Disable default assignment operator.

Private Attributes

GLuint m_FBO
 Framebuffer Object GL name.
GLuint m_depthRBO
 Renderbuffer for depth component.
ArrayElement m_images [VR3FBO_MAX_IMAGES]
 Texture images attached to every attachment point.
GLsizei m_width
 Width of the FBO (shared among all images)
GLsizei m_height
 Height of the FBO (shared among all images)

Detailed Description

The FBO class.

FBO stands for Framebuffer Object, a Framebuffer Object represents something the GL is capable of rendering into. The default GL behaviour is to render objects to the default Framebuffer Object, which is the one associated with the GL window and cannot be manipulated by the user. This class is used to declare, initialize and eventually use a different Framebuffer Object for GL rendering. This is called off-screen rendering. The rendered data may be written on textures to be used later on for more rendering passes. Example usages of this solutions are:

A single FBO may be associated with many different images rendered at once while rendering to the FBO. Every single image is associated with a color attachment number. Up to a total of the minimum between the implementation-dependent constants GL_MAX_COLOR_ATTACHMENTS and GL_MAX_DRAW_BUFFERS images may be attached to a single FBO. When using the standard shaders, the only image rendered will be the one attached to GL_COLOR_ATTACHMENT0. When using a user-defined shader, output color fragColorX will be written to the image attached to GL_COLOR_ATTACHMENTX. The total number of color attachment will always be bounded to VR3FBO_MAX_IMAGES (implementation-independent constant). The Framebuffer Object is always provided with a depth component only Renderbuffer Object. This is necessary to enable depth comparison and proper scene rendering. Contents of the depth renderbuffer object cannot be used as a texture. If depth information is needed as a texture, the user is encorauged to write it on one of the available color attachments.

NOTE: While the default shaders may be used to render the scene to a user-defined Framebuffer Object, they are not capable to use the obtained texture images in any way. User-defined shaders must be used to work with the obtained images.

NOTE: The built-in shadow mapping method uses GL FBOs to implement the used EVSM algorithm, but this class is not used. Indeed, as previously noted, the default built-in shaders are not capable of accessing the texture images generated using this FBO class.

Definition at line 67 of file VR3FBO.h.


Constructor & Destructor Documentation

VR3FBO::VR3FBO ( const VR3FBO  ) [private]

Disable default copy constructor.

VR3FBO::VR3FBO ( GLsizei  width,
GLsizei  height 
)

Constructor of the class.

This function builds a ne VR3FBO object with no images attached to it, something must be attached to it in order to start using the FBO.

Parameters:
[in]width,heightSize of the FBO.
VR3FBO::~VR3FBO (  )

Destructor of the class.

Destroys the FBO and every texture images that was previously bound to the framebuffer object.


Member Function Documentation

void VR3FBO::ActivateTexture ( int  attachpoint,
unsigned int  unit_id 
)

Activates a texture image on a specified texture unit.

Activates the texture image attached to the given attachpoint as the active texture (for shading) in unit unit_id. The unit_id meaning is the same we have in the VR3Texture::Activate() method.

Parameters:
[in]attachpointThe desired color attachment point (integer value)
[in]unit_idThe unit_id to bind the texture to (same as written in the sampler)
void VR3FBO::AddImage ( int  attachpoint,
GLint  internalformat,
GLenum  format,
GLenum  type 
)

Adds a new texture image to an attachment point.

This method is used to add a new image to one of the available attachment points. An error will arise if the attachpoint parameter is not valid considering the maximum color attachments upper bound, or if the specified attachment point is already bounded to another texture image.

Parameters:
[in]attachpointThe desired color attachment point (integer value)
[in]internalformatThe new texture image internal format
[in]formatThe new texture image format
[in]typeThe new texture image data type
VR3FBO& VR3FBO::operator= ( const VR3FBO  ) [private]

Disable default assignment operator.

void VR3FBO::SetFiltering ( int  attachpoint,
GLint  min_filter,
GLint  mag_filter 
)

Activates a texture image on a specified texture unit.

Sets the filtering method to use for the texture image attached to the specified attachment point. If GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR is specified as minification filter, mipmaps will automatically be generated when the texture image is activated with the VR3FBO::ActivateTexture() function.

Parameters:
[in]attachpointThe desired color attachment point (integer value)
[in]min_filterThe texture minification filter
[in]mag_filterThe texture magnification filter
void VR3FBO::Start (  )

Activates the Framebuffer Object.

This method activates the framebuffer object. Each drawing operation executed after this call will be performed to this framebuffer. An error will arise if the framebuffer object is not complete. This function is called by the proper Begin() function and may not be called directly by the user.


Member Data Documentation

GLuint VR3FBO::m_depthRBO [private]

Renderbuffer for depth component.

Definition at line 73 of file VR3FBO.h.

GLuint VR3FBO::m_FBO [private]

Framebuffer Object GL name.

Definition at line 70 of file VR3FBO.h.

GLsizei VR3FBO::m_height [private]

Height of the FBO (shared among all images)

Definition at line 91 of file VR3FBO.h.

ArrayElement VR3FBO::m_images[VR3FBO_MAX_IMAGES] [private]

Texture images attached to every attachment point.

Definition at line 86 of file VR3FBO.h.

GLsizei VR3FBO::m_width [private]

Width of the FBO (shared among all images)

Definition at line 89 of file VR3FBO.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines