GLS  1.0.0
GL Stuff - A library aimed at reducing the boilerplate OpenGL code you always have to write.
renderbuffer Class Reference

Class encapsulating an OpenGL renderbuffer object. More...

#include <renderbuffer.hpp>

Public Member Functions

 renderbuffer (GLenum internal_format, GLsizei the_width, GLsizei the_height)
 Construct a gls::renderbuffer without multi-sampling. More...
 
 renderbuffer (GLsizei samples, GLenum internal_format, GLsizei the_width, GLsizei the_height)
 Construct a gls::renderbuffer with multi-sampling. More...
 
GLuint name () const
 Retrieve the OpenGL name of this renderbuffer. More...
 
GLsizei width () const
 Retrieve the width of the allocated renderbuffer storage. More...
 
GLsizei height () const
 Retrieve the height of the allocated renderbuffer storage. More...
 
void bind ()
 Bind this renderbuffer. More...
 

Static Public Member Functions

static void unbind ()
 Unbind the currently bound renderbuffer. More...
 

Detailed Description

Class encapsulating an OpenGL renderbuffer object.

A gls::renderbuffer is an object that encapsulates an OpenGL renderbuffer object.

Like all objects in GLS, the underlying name is generated at object construction and deleted at destruction. This can be retrieved with name(). Additionally, the storage for the renderbuffer is automatically allocated at construction as well.

gls::renderbuffer objects are only used as part of gls::framebuffer objects. If you want, you can also manually attach the gls::renderbuffer object to your own framebuffer object using name().

To bind a gls::renderbuffer, simply call bind(). It will bind the gls::renderbuffer to the GL_RENDERBUFFER binding point and replace any previously bound to that target. To clear the binding to that target, call unbind().

Example usage:

auto framebuffer = gls::framebuffer();
framebuffer.add_renderbuffer( GL_DEPTH_ATTACHMENT, gls::renderbuffer( GL_DEPTH_COMPONENT24, 100, 100 ) );
framebuffer.bind();
... draw stuff to the depth renderbuffer ...
framebuffer.unbind();

Constructor & Destructor Documentation

renderbuffer ( GLenum  internal_format,
GLsizei  the_width,
GLsizei  the_height 
)

Construct a gls::renderbuffer without multi-sampling.

Renderbuffer storage is automatically allocated.

Parameters
internal_formatInternal format of the renderbuffer storage
the_widthWidth of the renderbuffer storage
the_heightHeight of the renderbuffer storage
renderbuffer ( GLsizei  samples,
GLenum  internal_format,
GLsizei  the_width,
GLsizei  the_height 
)

Construct a gls::renderbuffer with multi-sampling.

Renderbuffer storage is automatically allocated.

Parameters
samplesNumber of samples to use for the renderbuffer storage
internal_formatInternal format of the renderbuffer storage
the_widthWidth of the renderbuffer storage
the_heightHeight of the renderbuffer storage

Member Function Documentation

GLuint name ( ) const

Retrieve the OpenGL name of this renderbuffer.

Returns
OpenGL name of this renderbuffer
GLsizei width ( ) const

Retrieve the width of the allocated renderbuffer storage.

Returns
Width of the allocated renderbuffer storage
GLsizei height ( ) const

Retrieve the height of the allocated renderbuffer storage.

Returns
Height of the allocated renderbuffer storage
void bind ( )

Bind this renderbuffer.

static void unbind ( )
static

Unbind the currently bound renderbuffer.