After much longer than I expected it to take, I've finally checked-in my changes to the way the openGL classes work!
The TL;DR is:
- OpenGLComponent no longer exists
- Instead, you create an OpenGLContext object yourself, and then attach it to ANY component using the attachTo() method.
- That'll take care of rendering the component paint() using a GL 2D context, so you can use it to GL-accelerate the rendering on any component without needing to change the component itself.
- If you want to use a renderOpenGL() callback, you just have to provide an object that inherits from OpenGLRenderer, and pass that to the context object to use. (Doing this means you'll end up with something pretty similar to the way it all used to work, as OpenGLRenderer has similar callbacks to the old OpenGLComponent class)
- Before you delete your OpenGLRenderer object or your component, you call OpenGLContext::detach() (or delete the context) to let it clean-up.
- If you want to specify pixel formats, etc, you tell the context object about that before calling attachTo()
This new arrangement also fits with the way the Android classes work, which means that GL's now also available on Android! (Well, on devices that support GLES 2.0)
Have a look at the juce demo for an example - in fact there are actually very few lines of code that needed to change to make that work.
Enjoy! Your feedback on whether it all works smoothly would be much appreciated, and let me know if I've forgotten to implement any vital bits of functionality that you need!