glcxx: A Modern C++ Interface to OpenGL Object Management
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
glcxx::Program Class Reference

C++ wrapper for an OpenGL program object. More...

#include <Program.hpp>

Public Member Functions

 Program ()
 Create and allocate an OpenGL program object.
 
 ~Program ()
 Destroy the program object.
 
GLuint id () const
 Get the program object's ID. More...
 
void use () const
 Use the program.
 
template<typename... Shaders>
void build (Shaders...shaders)
 Utility method to attach shaders and link the program. More...
 
void attach_shader (const Shader &shader) const
 Attach a shader to the program. More...
 
void attach_shader (std::unique_ptr< Shader > shader) const
 Attach a shader to the program. More...
 
void attach_shader (std::shared_ptr< Shader > shader) const
 Attach a shader to the program. More...
 
void link () const
 Link the program.
 
GLint get_uniform_location (const char *uniform_name)
 Get the index of a uniform variable in the program. More...
 

Static Public Member Functions

template<typename... Args>
static std::shared_ptr< Programcreate (Args...args)
 Factory method to construct a Program object. More...
 

Protected Member Functions

void allocate ()
 Allocate an OpenGL program object.
 
void _build () const
 Internal helper to build().
 
template<typename... Shaders>
void _build (const Shader &shader, Shaders...args) const
 Internal helper to build().
 
template<typename... Shaders>
void _build (std::unique_ptr< Shader > shader, Shaders...args) const
 Internal helper to build().
 
template<typename... Shaders>
void _build (std::shared_ptr< Shader > shader, Shaders...args) const
 Internal helper to build().
 
template<typename... Shaders>
void _build (const char *attribute_name, GLuint index, Shaders...args) const
 Internal helper to build().
 

Protected Attributes

GLuint m_id
 The program object's ID.
 

Detailed Description

C++ wrapper for an OpenGL program object.

Member Function Documentation

void glcxx::Program::attach_shader ( const Shader shader) const
inline

Attach a shader to the program.

Parameters
shaderThe shader to attach.
void glcxx::Program::attach_shader ( std::unique_ptr< Shader shader) const
inline

Attach a shader to the program.

Parameters
shaderThe shader to attach.
void glcxx::Program::attach_shader ( std::shared_ptr< Shader shader) const
inline

Attach a shader to the program.

Parameters
shaderThe shader to attach.
template<typename... Shaders>
void glcxx::Program::build ( Shaders...  shaders)
inline

Utility method to attach shaders and link the program.

This method automatically invokes attach_shader() for each shader given and then invokes link() to link the program.

Parameters
shadersA std::unique_ptr<Shader>, std::shared_ptr<Shader>, or const Shader &.
template<typename... Args>
static std::shared_ptr<Program> glcxx::Program::create ( Args...  args)
inlinestatic

Factory method to construct a Program object.

Parameters
argsThe arguments given are passed to the constructed Program's build() method.
Returns
std::shared_ptr to a Buffer.
GLint glcxx::Program::get_uniform_location ( const char *  uniform_name)
inline

Get the index of a uniform variable in the program.

Parameters
uniform_nameName of the uniform variable.
Returns
Index of the uniform variable.
GLuint glcxx::Program::id ( ) const
inline

Get the program object's ID.

Returns
The program object's ID.

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