I can't seem to get a good grasp on how these OpenGLAppComponents come and go. Can someone please correct my thinking if it is wrong?
1) Object is created that inheirts from OpenGLAppComponents and Timer. Object exists in the AudioProcessorEditor.
2) Call initialise() (This is where we attach to an openGLContext? A timer is started.)
3) addAndMakeVisible(&my_gl_appcomponent); is called from the editor, telling it that this will be drawn.
4) my_gl_appcomponent.setBounds(...) is called specifying the size and location of the GL component.
5) The timer callback calls repaint() repeatedly, updating your display.
6) When the editor is closed, we call shutdown(), where we detach from the openGLContext.
7) Delete my_gl_component, calling shutdownOpenGL() in the destructor
8) We are free to open the editor again, goto 2.
Am I missing anything? Do I have extra things? I've been trying to find the cause of this GL_INVALID_FRAMEBUFFER_OPERATION error for the second day in a row and I'm getting pretty frustrated.
Have you checked out the OpenGLAppExample?
Using a Timer to render a frame sounds wrong, and a likely suspect for your framebuffer crash.
Do as per that example; inherit from OpenGLAppComponent and override render() and see if that fixes it.
You can create an audio plugin with an editor containing an OpenGL component by following my suggestion in my other post:
For example, your component shouldn't need to inherit from Timer. Additionally, you should not be calling initialise yourself.
Life cycle is as follows:
1) Object is created that inheirts from OpenGLAppComponent (do not inherit from Timer) -> this will call initialise
2) addAndMakeVisible is called from your editor (if necessary you can also set the size and name of the OpenGLAppComponent )
3) repaint is called automatically: no need to worry about this
4) when the editor is closed (and you have used a ScopedPointer to store a reference to your OpenGLAppComponent), the destructor of your OpenGLAppComponent is called automatically (you need to do nothing explicetely). Your destructor should now call shutdownOpenGL which will detach yourself from the openGl context.
5) when the editor is opened again you need to go back to 1), aka recreate the OpenGLAppComponent object.
Does this clarify things for you?
How do I know that GL isn't just re-rendering as fast as it can without the timer callback?
OpenGL will repaint only when necessary. Calling it additionally from a timer will in fact slow down performance as your calls will be in addition to the ones generated automatically.
Can you elaborate on "only when necessary"? If I've got it drawing pixels from an array of data, GL doesn't know when the data is changed.
If you turn on continuous repaint:
then you do not need to call repaint. This is the preferred way of doing things. Note that the overhead if simply painting is very low with OpenGL. Therefore, continuously repainting should not significantly increase CPU usage.