OGLplus (0.49.0) a C++ wrapper for OpenGL

OGLplus - a C++ wrapper for modern OpenGL®.
oglplus.png

OGLplus is a header-only library which implements a thin object-oriented facade over the OpenGL® (version 3 and higher) C-language API. It provides wrappers which automate resource and object management and make the use of OpenGL in C++ safer and easier.

Features

OGLplus adds the following functionality to the OpenGL® C API.

Automatic resource management

Applications using the OpenGL® library typically allocate and use, during their run-time, resources like buffers, queries, textures, shaders, programs, etc. from this library. OGLplus uses the RAII idiom to automatically manage the lifetime of these resources. Classes like Buffer, Texture, Query, Shader, Program, Framebuffer, Renderbuffer, etc. automatically get a new OpenGL name for the wrapped object when an instance is constructed and it is freed when the instance is destroyed. Besides this basic functionality, the individual classes also implement member functions wrapping those calls which are related to the resource managed by the particular class.

When several instances of the same resource type should be created and freed at the same time, the Array template provides efficient means for doing so.

Type safety

OpenGL uses the GLuint type as the namespace for instances of different types of resources (textures, shaders, programs, etc.) and thus it is very easy to make an error and use a name originally allocated for a shader as a parameter for a call expecting for example a name of a occlusion query, and such errors will not be caught by the compiler.

By implementing the wrapper classes OGLplus gives a special meaning to the unsigned integer names and by their encapsulating and hiding from the library client it allows to avoid such errors.

Similarly the various enumerations are basically values of the GLenum type and are prone to the same kind of error. You can pass an incompatible enumerated value to a API function call. OGLplus again allows to avoid these errors by separating the values into strongly typed enums and wrapping the basic OpenGL® API calls by functions accepting only parameters with matching enumerated types.

Error handling and diagnostic

In cases where errors cannot be caught at compile-time by using the type system or by other means, OGLplus checks for errors after the calls to OpenGL and throws an exception if an error occurs. All exceptions are derived from the Error class which provides information about the throw site of the exception (source file, line, OGLplus function name, the OpenGL® C API call, etc. where the error occured) and optionally also some properties (string key and value) attached at the throw site or during the propagation of the exception. If the error is related to a described object, then the object description can also be obtained for a more precise diagnostic.

Interoperability with OpenGL® C API

As said above, OGLplus by default encapsulates and hides the OpenGL names assigned to various objects (resources allocated at the OpenGL server). There are however situations where it might be necessary to get this "raw" resource handle.

Additional CG related classes

Besides the classes wrapping OpenGL functionality OGLplus also provides several classes which are related to computer graphics and indirectly to OpenGL, like Angle, Vector, Matrix, BezierCurves, and several others, but does not force you to use them if you don't want to.

Optional object description

Objects with OpenGL names (unsigned integers) can optionally have a textual description. This is useful for diagnostic purposes, for example in an application with lots of different shaders it is easier to track the source of compilation, linking or validation errors when the individual shader or program objects have a human-readable description which is attached to the exception raised by the error.

Configurability

If the overhead caused by the object descriptions or other run-time checks (which are useful during the development and/or debugging) is unacceptable for release builds of an application using OGLplus, they can all be compiled away by setting the value of the #OGLPLUS_LOW_PROFILE preprocessor symbol. Individual features can be also enabled or disabled independently as required by setting the appropriate oglplus_configuration_options.

What OGLplus isn't

Like the OpenGL® C API, OGLplus does not officially provide nor force you to use code related to creating of the default framebuffer. There are already several other libraries and frameworks which do it in both platform dependent and platform independent ways.

OGLplus also does not include header file(s) declaring the OpenGL® 3 (or higher) function prototypes and enumerated values. It is the responsibility of the application to do so. There are several ways how to do it, see Getting it going for some suggestions.

Getting started

One of the best ways how to get yourself acquainted with the library is to look at the examples and to browse through the reference. Many of the examples are thoroughly commented and for some of them step-by-step tutorials are being added. Also see Getting it going for a detailed help on building the examples and your own applications.


Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Tue Jul 29 2014 by Doxygen (version 1.8.6).