JuceDemo OpenGL3 request

Seeing that JUCE supports OpenGL 3, it would seem useful to allow users to test it within the demo.

Here’s an explicit initialisation, but probably an option to toggle between the default OpenGL context and 3.2 would be better.

void MainAppWindow::setRenderingEngine (int index)
    showMessageBubble (getRenderingEngines()[index]);

    if (getRenderingEngines()[index] == openGLRendererName
          && contentComponent != nullptr
          && ! contentComponent->isShowingOpenGLDemo())
       #if JUCE_OPENGL3
        openGLContext.setMultisamplingEnabled (true); //FYI: This can't be called multiply if the current renderer is the same - the method jasserts
        openGLContext.setOpenGLVersionRequired (OpenGLContext::openGL3_2);

        openGLContext.attachTo (*getTopLevelComponent());


    if (ComponentPeer* peer = getPeer())
        peer->setCurrentRenderingEngine (index);

There is something a bit strange about doing this; on my Mac Mini, glGetString (GL_VERSION) returns 4.1 INTEL-10.22.29 with this 3.2 setting. I guess the native context just picks the latest, making setting the version more of a hint instead? The code looks right: JUCE is setting NSOpenGLProfileVersion3_2Core, even though NSOpenGLProfileVersion4_1Core is an option for 10.10 and above. Oh well - if it works, whatever!

TBH I think it’s fair to say we only support GL 3 and there’s not really any reason to support older versions any more. A little task for us should be to remove the legacy code that refers to older versions…

For desktop apps that makes definite sense.

Just in case you want to encompass GLES3 underneath that idea, do note that only Android 4.3 (API 18) and above support it. Tangentially related, I brought up a minor concern about the present default API level in the Android category.

I could be mistaken, but the last I read about OpenGL ES 3, textures required a minimum size of 2048 x 2048. Seemed like a pretty big change if you’re drawing small quads to the screen with individual images as opposed to a texture atlas.

Rather certain ES3 is backwards compatible with ES2 meaning the minimum texture size is still 64 px².

The max texture size for a 2D texture image is 2048 px². For 3D it’s 256 px².

See 6.2. STATE TABLES in the spec:

If you want to compare ES specs:

You’re absolutely right. I must have misread an Apple document on OpenGL ES reading the maximum texture size as a minimum.