The base OpenGL API quickly becomes cumbersome and unmaintainable for large projects, so I always find it necessary to abstract the OpenGL API. This is simple with buffers, shaders, windows, textures, etc. The problem comes when trying to merge these aspects. Take a hypothetical class, object.


class object
    void attach_vertices(T points);
    void attach_texture(texture t);
    void draw();

The complication comes in when trying to use shaders. At minimum, this object class will need to know relevant attribute locations, texture locations and bindings, and any other necessary uniforms. One solution is to completely control the shader program within the object class, but this is quite inflexible, making things like lighting impossible, or at least inelegant.

How can I elegantly and efficiently abstract the OpenGL API, distinguishing objects and textures from shader programs? What sort of paradigm is, in your opinion, the most maintainable and flexible for use with OpenGL? If the answer is to just not abstract it, how do make your code readable and maintainable?

I appreciate all replies; I'm asking for opinions, as there is not one solution for every situation.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum