Unofficial OpenGL Software Development Kit  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Member Functions
glutil::UniqueProgram Class Reference

#include <Shader.h>

Inherits noncopyable.

RAII object for managing a program object.

This object manages the lifetime of a program object. It represents a uniquely-owned program object. It is implicitly convertible to GLuint, so you can use it more or less wherever you used a GLuint before.

It is explicitly non-copyable. C++11 would eventually allow move-semantics, but that's not widely available enough to directly support. If you need to transfer ownership, it is swappable, so you'll have to make due with using `swap`.

This RAII-style class makes it easy to be exception-safe with program objects.

Todo:
: Implement C++11 move semantics.

Public Member Functions

 UniqueProgram ()
 An empty UniqueProgram, with program name 0.
 
 UniqueProgram (GLuint program)
 Create a UniqueProgram from an existing program object.
 
 ~UniqueProgram ()
 Destroys the owned program object, if any.
 
void swap (UniqueProgram &other)
 Exchanges program ownership between the two objects.
 
 operator GLuint () const
 Implicit conversion to program object.
 
void reset (GLuint newProgram=0)
 The given program becomes the current program; the old one is deleted.
 
GLuint release ()
 Abandons ownership of the currently-owned program object. More...
 

Member Function Documentation

GLuint glutil::UniqueProgram::release ( )
inline

Abandons ownership of the currently-owned program object.

After calling this function, the program object will be unowned. It will not have been destroyed.

Returns
The program object that used to be owned.

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