SenOGL  0.2
Library aiming to ease the use of OpenGL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Framebuffer< TexType, ColorCount, DepthType, UseDepth > Class Template Reference

Framebuffer Object (FBO) More...

#include <Framebuffer.hpp>

Inheritance diagram for Framebuffer< TexType, ColorCount, DepthType, UseDepth >:
OpenGLObject

Public Types

using depth_type = DepthType
 
using color_type = TexType
 

Public Member Functions

 Framebuffer (size_t size=512)
 Default constructor. More...
 
 Framebuffer (size_t width, size_t height)
 Constructor for a rectangular framebuffer. More...
 
virtual ~Framebuffer ()
 Destructor. More...
 
virtual void init () override
 Initialize the OpenGLObject. More...
 
virtual void cleanup () override
 Destroys OpenGL object. More...
 
void bind (FramebufferTarget target=FramebufferTarget::All) const
 Bind this framebuffer. More...
 
void clear () const
 Clear the framebuffer. More...
 
void clear (BufferBit target) const
 Clear the framebuffer. More...
 
TexType & getColor (unsigned int i=0)
 
TexType & getDepth ()
 
const TexType & getColor (unsigned int i=0) const
 
const DepthType & getDepth () const
 
size_t getWidth () const
 
size_t getHeight () const
 
void attach (const Texture &tex, GLenum attachment) const
 
void attach (const Renderbuffer &buf, GLenum attachment) const
 
- Public Member Functions inherited from OpenGLObject
 OpenGLObject ()
 
 OpenGLObject (GLuint handle)
 Constructs a instance managing an existing OpenGL Object. More...
 
 OpenGLObject (const OpenGLObject &)=default
 
 OpenGLObject (OpenGLObject &&)=default
 
OpenGLObjectoperator= (const OpenGLObject &)=default
 
OpenGLObjectoperator= (OpenGLObject &&)=default
 
virtual ~OpenGLObject ()
 
GLuint getName () const
 Returns OpenGL name of the object. More...
 
void setName (GLuint n)
 Sets the OpenGL name of the object managed by this instance /!\ Use with caution ! (assignment operator is probably what you're looking for) More...
 
virtual bool isValid () const
 Returns true if the object seems valid. More...
 
 operator bool () const
 Syntactic sugar for isValid(). More...
 

Static Public Member Functions

static void unbind (FramebufferTarget target=FramebufferTarget::All)
 Unbind any FBO currently bound to target. More...
 

Additional Inherited Members

- Protected Attributes inherited from OpenGLObject
GLuint _handle
 OpenGL name of the managed object. More...
 

Detailed Description

template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
class Framebuffer< TexType, ColorCount, DepthType, UseDepth >

Framebuffer Object (FBO)

Parameters
TexTypeType of the textures attached to the framebuffer.
ColorCountNumber of Color buffers (attachments).
Todo:
More initialization options!

Member Typedef Documentation

template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
using Framebuffer< TexType, ColorCount, DepthType, UseDepth >::color_type = TexType
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
using Framebuffer< TexType, ColorCount, DepthType, UseDepth >::depth_type = DepthType

Constructor & Destructor Documentation

template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
Framebuffer< TexType, ColorCount, DepthType, UseDepth >::Framebuffer ( size_t  size = 512)

Default constructor.

Parameters
sizeResolution of the framebuffer (internal textures).
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
Framebuffer< TexType, ColorCount, DepthType, UseDepth >::Framebuffer ( size_t  width,
size_t  height 
)

Constructor for a rectangular framebuffer.

Parameters
widthX Resolution of the framebuffer (internal textures).
heightY Resolution of the framebuffer (internal textures).
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
virtual Framebuffer< TexType, ColorCount, DepthType, UseDepth >::~Framebuffer ( )
virtual

Destructor.

Member Function Documentation

template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::attach ( const Texture tex,
GLenum  attachment 
) const
inline
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::attach ( const Renderbuffer buf,
GLenum  attachment 
) const
inline
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::bind ( FramebufferTarget  target = FramebufferTarget::All) const

Bind this framebuffer.

Parameters
target(FramebufferTarget::)Draw, Read or All
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
virtual void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::cleanup ( )
overridevirtual

Destroys OpenGL object.

Implements OpenGLObject.

template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::clear ( ) const

Clear the framebuffer.

Equivalent to a call to clear(GLenum target) with Buffer::Color if any color buffer is attached to it, and Buffer::Depth if using depth.

See also
clear(GLenum target)
glClear
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::clear ( BufferBit  target) const

Clear the framebuffer.

Parameters
targetCombinaison of Buffer
See also
clear()
glClear
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
TexType& Framebuffer< TexType, ColorCount, DepthType, UseDepth >::getColor ( unsigned int  i = 0)
inline
Parameters
iIndex of the color buffer.
Returns
Texture attachment to ith color buffer.
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
const TexType& Framebuffer< TexType, ColorCount, DepthType, UseDepth >::getColor ( unsigned int  i = 0) const
inline
Parameters
iIndex of the color buffer.
Returns
Texture attachment to ith color buffer.
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
TexType& Framebuffer< TexType, ColorCount, DepthType, UseDepth >::getDepth ( )
inline
Returns
Texture of the Depth buffer.
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
const DepthType& Framebuffer< TexType, ColorCount, DepthType, UseDepth >::getDepth ( ) const
inline
Returns
Texture of the Depth buffer.
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
size_t Framebuffer< TexType, ColorCount, DepthType, UseDepth >::getHeight ( ) const
inline
Returns
Height of the framebuffer.
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
size_t Framebuffer< TexType, ColorCount, DepthType, UseDepth >::getWidth ( ) const
inline
Returns
Width of the framebuffer.
template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
virtual void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::init ( )
overridevirtual

Initialize the OpenGLObject.

Implements OpenGLObject.

template<typename TexType = Texture2D, unsigned int ColorCount = 1, typename DepthType = Renderbuffer, bool UseDepth = true>
static void Framebuffer< TexType, ColorCount, DepthType, UseDepth >::unbind ( FramebufferTarget  target = FramebufferTarget::All)
inlinestatic

Unbind any FBO currently bound to target.

(Restore default framebuffer)

Parameters
targetTarget

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