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:
- Do not introduce new semantics.
- Do not hide steps, by creating all-in-one functions.
- Try to use common names with OpenGL C API to avoid confusion.
- Use C++ language to represent OOP semantics (e.g. OpenGL objects )
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();
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
Doxygen is used for in-code documentation. You can build documentation files by simply running doxygen on the top folder where Doxyfile resides.
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.