OpenGLContext: refactor into OpenGLWidget + OpenGLContext + OpenGLFunctions
TL;DR OpenGLWidget: GUI/User stuff OpenGLContext: GL states and stuff OpenGLFunctions: GL functions and defines stuff
This is probably the biggest part of the low level VL effort which may make VL a lot more useful to may more people.
vl::OpenGLContext is a bit of a mixed bag right now, it handles some OpenGL stuff and also some GUI stuff, and it does not handle render states management, opengl object management and cross context resource sharing. It also relies on the GUI binding to swapBuffers() and makeCurrent() which is tricky.
Render state management is handled by vl::Renderer instead of OpenGL context which means that multiple vl::Renderer have to cooperate with each other.
A better design would be to do render state management in one place inside vl::OpenGLContext.
An even better design would be to have a vl::OpenGLFunctions that wraps in a .cpp all the GL functions, extensions, values, defines etc. which in turn is used by vl::OpenGLContext and vl::Renderer. Pro: we do not expose GL headers in any .hpp file avoiding conflicts and such.
Steps:
- Implement vl::OpenGLFunctions and use it everywhere. (big one)
- Move render state management from vl::Renderer to vl::OpenGLContext. vl::OpenGLContext might actually derive from vl::OpenGLFunctions. (doable)
- Factor out vl::OpenGLWidget, fix GUI binding and examples or investigate way to go about it. (tricky)
Cons Examples and GUI bindings may need to be substantially rewritten.
It would be nice to implement an interface similar to that of Qt's: QAbstractOpenGLFunctions QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions http://doc.qt.io/qt-5/qopenglcontext.html#versionFunctions http://doc.qt.io/qt-5/qabstractopenglfunctions.html
That is, a wrapper class of all OpenGL functions and some extra flags to summarise the main capabilities of the current OpenGL context.