GLS  1.0.0
GL Stuff - A library aimed at reducing the boilerplate OpenGL code you always have to write.
object< Generator, Deleter > Class Template Reference

A RAII wrapper around any OpenGL object. More...

#include <object.hpp>

Public Member Functions

 object ()
 Default constructor. More...
 
 ~object ()
 Default destructor. More...
 
 object (object &&other)
 Move constructor. More...
 
objectoperator= (object &&other)
 Move assignment. More...
 
GLuint name () const
 Retrieve the OpenGL name of this buffer. More...
 

Detailed Description

template<void(*)(GLsizei, GLuint *) Generator, void(*)(GLsizei, const GLuint *) Deleter>
class gls::object< Generator, Deleter >

A RAII wrapper around any OpenGL object.

A gls::object is a simple wrapper object any type of OpenGL object that has functions to generate and delete names.

Template Parameters
Generatorvoid(GLsizei, GLuint*) function that generates the name
Deletervoid(GLsizei, const GLuint*) function that deletes the name

The object name is generated when the gls::object is constructed and deleted when it is destroyed. It be retrieved with name().

gls::object and all the other GLS classes that use it are move-only.

The generator template parameter has the signature: void(GLsizei, GLuint*) and the deleter template parameter has the signature: void(GLsizei, const GLuint*)

Note: gls::object takes as its template parameters function pointers with the default calling convention for your compiler/architecture. If you want to call functions with differing calling conventions, you will have to wrap those in your own free functions which you can pass to gls::object.

Example usage:

namespace priv {
void my_gen_buffers( GLsizei size, GLuint* name ) { glGenBuffers( size, name ); }
void my_delete_buffers( GLsizei size, GLuint* name ) { glDeleteBuffers( size, name ); }
}
int main() {
... create an OpenGL context ...
auto a_buffer_object = my_buffer_object();
... some other stuff ...
}

Constructor & Destructor Documentation

object ( )

Default constructor.

~object ( )

Default destructor.

object ( object< Generator, Deleter > &&  other)

Move constructor.

Parameters
otherOther object that is being moved from

Member Function Documentation

object& operator= ( object< Generator, Deleter > &&  other)

Move assignment.

Parameters
otherOther object that is being assigned from
Returns
*this
GLuint name ( ) const

Retrieve the OpenGL name of this buffer.

Returns
OpenGL name of this buffer