• Advertisement
Sign in to follow this  

ObjectGL, an object-oriented OpenGL 3.x/4.x wrapper for .NET

This topic is 2034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


Some time ago I have started working with OpenGL 3.x and I liked very much how it was designed around objects (VAOs, VBOs, Samplers, Textures etc). But the C API itself was to me (and still is) a complete counter-intuitive mess, full of functions that take implicit parameters and produce unexpected side effects.

After it was clear that trying to remember all the nuances of the API functions will be too error-prone and time-consuming, I decided to write a small wrapper API that will allow me to work with OpenGL in terms of OpenGL objects without the 'bind-to-edit'-like mindset. Well, here it is.


As a short example of how ObjectGL makes things more intuitive and closer to the OpenGL object model, consider that we want to create and initialize an index buffer.

In OpenGL we have to writre

GLuint handle;
glGenBuffers(1, &handle);
glBindVertexArray(0); // So that we don't change the index buffer of the currently-bound VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handle);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indexData, GL_STATIC_DRAW);

And by doing so we also produce a side effect of unbinding the VAO from the pipeline, which we will have to remember about.

In ObjectGL we just write

var indexBuffer = new Buffer(context, BufferTarget.ElementArrayBuffer, size, BufferUsageHint.StaticDraw, new Data(indexData));

And ObjectGL handles all the bindings behind the scenes without any side effects, trying to use as few OpenGL calls as possible.

While still being under development and missing some functionality, ObjectGL already supports many of the significant Core OpenGL features like geometry and tesselation shaders. And while it was first created as small tool for myself, I now think that many people can benefit from it.

So, please, let me know what you think of it, what you like, what you dislike, what would you like to be implemented next, and just anything you want to say about the project. I would also gladly answer any of your questions.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement