Multiple glViewport calls?

I noticed that there are 2 calls to glViewport: one with the renderer (if there is one set) and one within the standard component drawing routine. I’m not sure what use cases there would be for having multiple calls to this function, especially since it’s expensive to do.

Local tests on various desktop platforms show that it’s possible to simplify this into one single call. Haven’t the time to test on mobile though I would expect it to give the same result.

Proposed changes.

The problem is that the renderOpenGL callback may also change the viewport. In fact, in ROLI’s NOISE app on android, the whole screen is an OpenGLRenderer and we pass the renderOpenGL callback to the different visualisers that want to show some GL visualisations - this ensures that the entire app is accelerated with OpenGL but we can still use OpenGL shaders for visualisations. I think this is a technique that many Android apps may use as software rendering the JUCE GUI elements is dead slow on Android.

In any case, each visualiser will call glViewport to limit it’s drawing to only the bounds of the visualisation.

Multiple glViewport calls is still a rather slow approach as it applies an entire transformation. Wouldn’t a scissor test with shaders afterwards do a better/faster job for what you’re trying to do?

Yes, but we still can’t be sure that the user doesn’t call glViewport in the render callback.