-
Notifications
You must be signed in to change notification settings - Fork 58
Home
globjects is an object wrapper library for OpenGL. The OpenGL API is very powerful, but it's a pain to use, many functions, global state, and even though there are things like OpenGL objects, the API is not object-oriented at all. The goal of globjects is to add a thin layer on top of OpenGL to simplify the usage of its API in an object-oriented manner. However, the goal is not to add an abstraction layer that hides everything (e.g. like OSG and Qt does) and robs the user of control. All the OpenGL objects (e.g. textures, buffers, etc.) can be found as real objects in globjects. Methods are usually named after their OpenGL function counterparts, and the parameters are the same. E.g. glMapBuffer becomes Buffer::map. Sometimes a convenience interface with less parameters is supported as well, but the raw OpenGL versions are always there. globjects does not try to restrict the power of OpenGL but tries to enhance the experience, by encapsulating the boring trivial tasks without trying to patronize you. It is also possible to intermix globjects commands and direct OpenGL calls without any trouble.
Let's have a quick look at some code snippets to get a feel of what globjects does.
globjects::Texture* texture = new globjects::Texture(GL_TEXTURE_2D);
texture->setParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
texture->setParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
unsigned char* data = ...
texture->image2D(0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
globjects::Program* program = new globjects::Program();
program->attach(
globjects::Shader::fromFile(GL_VERTEX_SHADER, "myshader.vert"),
globjects::Shader::fromFile(GL_FRAGMENT_SHADER, "myshader.frag")
);
program->setUniform<glm::vec2>("extent", glm::vec2(1.0, 0.5)));
globjects uses the CMake build system which handles most of the platform dependent issues.
Using batches, one can use the following configuration batch:
set GLBINDING_DIR=<path>
set GLM_HOME=<path>
set GLFW_LOCATION=<path>
set PATH=%GLEW_HOME%/bin;%PATH%;
And with that, configure and generate the project in CMake and open the solution/project in your the selected IDE. Note, that the working directory for all examples is expected to be the project's root directory.
The following bash snippet shows the globjects setup under Linux.
git clone https://github.com/cginternals/globjects.git globjects
cd globjects
./configure
After that, edit the created config files in .localconfig/ to your setup, and run:
./configure
cd build
make
If you want to compile in debug mode, add the flag -DCMAKE_BUILD_TYPE=Debug
.
On Linux, the configure script already created a .localconfig/debug configure file, so that you just need to run
./configure debug
cd build-debug
make
If NDEBUG
isn't defined during build, globjects will check for GL errors after each OpenGL call and output a message to the console.
If you want to know when exactly an error was triggered and where, add the option -DOPTION_ERRORS_AS_EXCEPTION=On
, which will throw exceptions when an OpenGL error is encountered.
This is particularly useful in connection with debuggers, where you will see a stack trace then.
By default, globjects disables exceptions completely for performance reasons.
globjects covers several OpenGL features and some supportive features useful for debugging and evaluation. More complex graphics related features or abstraction layers on top of OpenGL can be found in gloperate. For an introduction check out the following pages.
Initialization:
- [[Initializing the function pointers used by globjects|Initializing-globjects]]
OpenGL features:
- Basic rendering with Vertex Array Objects
- Deeper into Programs, Shaders and Uniforms
- Textures
- Framebuffer Objects and Attachments
- Buffers
- Transform Feedback
- GPU Time Measurement
Supporting features:
globjects Utils features:
globjects Window features: