Glpp

OpenGL C++ Wrapper


Project maintained by sque Hosted on GitHub Pages — Theme by mattgraham

GL++ (glpp)

OpenGL C++ Wrapper provides a C++ interface for the OpenGL API. The wrapper tries to expose all the logical objects of OpenGL standard to C++ native objects. This is not a graphics library, thus you will not find any assets manipulation or math functionality. However the library is designed to be easily coupled with an external math library like glm or an assets manipulation library like assimp.

The major keypoints of GL++ API are:

Comparison of using OpenGL C API and GL++

Creating a program and loading some shader files

OpenGL C API

// Prototype of a user function to load shader from file
int loadshader(char * filename, GLchar** ShaderSource, unsigned long* len);

GLuint vertexShader, fragmentShader, ProgramObject;
GLchar* shaderSource;
int shaderSourceLen;

vertexShaderObject = glCreateShader(GL_VERTEX_SHADER);
loadshader("shaderfile.vert", &shaderSource, &shaderSourceLen)
glShaderSource(vertexShader, 1, &shaderSource, &shaderSourceLen)
glCompileShader(vertexShader)

fragmentShaderObject = glCreateShader(GL_FRAGMENT_SHADER);
loadshader("shaderfile.frag", &shaderSource, &shaderSourceLen)
glShaderSource(vertexShader, 1, &shaderSource, &shaderSourceLen)
glCompileShader(vertexShader)

ProgramObject = glCreateProgram();
glAttachShader(ProgramObject, vertexShaderObject);
glAttachShader(ProgramObject, fragmentShaderObject);

glLinkProgram(ProgramObject);

Same on GL++

glpp::shared_program_t pprog;

pprog = new glpp::program();
pprog->attach_shader(
          glpp::open_shader_file(glpp::shader_type::VERTEX, "shaderfile.vert"));
pprog->attach_shader(
          glpp::open_shader_file(glpp::shader_type::FRAGMENT, "shaderfile.frag"));
pprog->build();
pprog->use();

Build

GL++ uses CMake build system. To continue you must ensure that you have the cmake installed on your system, and all the needed libraries.

To build the library you will need:

To build the examples you will need also:

It is preferred to build project in a sub-folder than doing it directly in tree.

mkdir build
cd build
cmake ..
make

Documentation

Doxygen is used for in-code documentation. You can view documentation online or you can build it using the given Doxyfile in the source folder.

Request For Help

OpenGL has a big API, with a lot of history and this is reflected in many domains. Studing the API and trying to find the best C++ representation requires a lot of effort. Any person who can help on this procedure can be useful for this project. Even jannitoring is also welcome.

Please contact me if you want to contribute.