OpenGL tutorial - The window pops up, but I am not seeing anything

Hello! I am trying to run the JUCE OpenGL tutorial project (JUCE: Tutorial: Build an OpenGL application).

The window pops up, but I am not seeing anything. I did copy the Resources folder (with the teapot file) into Projucer and resaved it. Do you have any suggestions or ideas as to why this may be happening?

JUCE v7.0.2
2023-05-23 13:01:57.127503-0400 OpenGLAppTutorial[1708:28454] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=1708
2023-05-23 13:01:57.127824-0400 OpenGLAppTutorial[1708:28454] SecTaskCopyDebugDescription: OpenGLAppTutoria[1708]/0#-1 LF=0
2023-05-23 13:01:58.339270-0400 OpenGLAppTutorial[1708:29016] Metal GPU Frame Capture Enabled
2023-05-23 13:01:58.339736-0400 OpenGLAppTutorial[1708:29016] Metal API Validation Enabled

You’re using quite an old version of JUCE. Do you see the same results with the newest version?

1 Like

With the latest version, I am getting the results as shown below.
However, nothing is still showing up.

JUCE v7.0.5
2023-05-23 15:18:24.516449-0400 OpenGLAppTutorial[2610:48081] Metal GPU Frame Capture Enabled
2023-05-23 15:18:24.516853-0400 OpenGLAppTutorial[2610:48081] Metal API Validation Enabled

I downloaded the demo and it works

To find out where the problem is, you should verify that each part is working, until you find what does not work. But it can be difficult if you don’t know OpenGL, since this will require modifying or adding some code.

I could suggest you to draw a simple model to at least know if the problem is in the shader or in the geometry, and reduce the problem

     glBegin(GL_TRIANGLES);
     glVertex3f(-1,0,0);
     glVertex3f(1,0,0);
     glVertex3f( 0,1.5,0);
     glEnd();

add this to the end of render(), since this drawing will use the current shader, if you see a rotating orange triangle then the shader seems to be fine, and the problem is with the rendering of the teapot

1 Like

Thank you for your reply @Marcusonic.
I added your code at the end of render() and still no dice.

I did not modify any code in the downloaded demo since I was expecting it to work as is.


Did your downloaded project work on your end without you having to modify any code?

I have downloaded the project and generated it with projucer for VS2022.

You can try to check if the problem is in the shader, remove the shader activation, this will force to use the fixed pipeline by activating the matrices by the old method.

    /*
    shader->use();                                                          // [5]
    
    if (uniforms->projectionMatrix.get() != nullptr)                        // [6]
        uniforms->projectionMatrix->setMatrix4 (getProjectionMatrix().mat, 1, false);

    if (uniforms->viewMatrix.get() != nullptr)                              // [7]
        uniforms->viewMatrix->setMatrix4 (getViewMatrix().mat, 1, false);
        */

    glMatrixMode(GL_PROJECTION);
    glLoadMatrixf(getProjectionMatrix().mat);
    glMatrixMode(GL_MODELVIEW);
    glLoadMatrixf(getViewMatrix().mat);

This should show the teapot with the default color (white)

1 Like

Thank you very much!
This code draws a white triangle when I add the code GL_TRIANGLES at the end!
Without adding GL_TRIANGLES, it still does not render the teapot.
The problem must be in the shader, and also with the rendering of the teapot.
I really appreciate it, @Marcusonic!

triangle:

teapot:

It seems as if it does not support modern opengl, for example varying is from 3.2

try to draw the triangle with this shader, you should see a blue triangle rotating (I have verified it)

    vertexShader = R"(
        attribute vec4 position;
        uniform mat4 projectionMatrix;
        uniform mat4 viewMatrix;
        void main()
        {
            gl_Position = projectionMatrix * viewMatrix * position;
        })";

    fragmentShader =
        R"(
           void main()
           {)"
        R"(    gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
           })";

Thank you @Marcusonic!
I used the shader above to draw the triangle and still got the same rotating white triangle.

Is the shader active? It’s strange that the shader doesn’t work and you don’t get any warning.

Even working fine, I get several warnings

JUCE v7.0.5
OpenGL DBG message: Buffer detailed info: Buffer object 1 (bound to GL_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations.
OpenGL DBG message: Buffer detailed info: Buffer object 2 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations.
OpenGL DBG message: Program/shader state performance warning: Vertex shader in program 2 is being recompiled based on GL state.
OpenGL DBG message: Buffer detailed info: Buffer object 3 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations.
OpenGL DBG message: Buffer detailed info: Buffer object 4 (bound to GL_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations.

Maybe you should go step by step, since an example like that is not going to understand anything. Create the body of your OpenGLAppComponent-derived class with the required override functions and test it with other easier tutorials LearnOpenGL - Hello Triangle

1 Like

Isn’t there another thread recently about OpenGL and macOS?

edit: yes → OpenGL broken on OSX?

It could well be related to either recent macOS and/or Apple Silicon. To rule out whether it’s recent macOS alone, I’ll try this out today on Intel mac mini running the latest version of macOS.

1 Like

It renders a triangle as expected when I create one using just OpenGL, GLFW, and Glad.

You should probably share your machine specs at this point as I was unable to repro on Intel macOS, latest Ventura (teapot loads fine).

1 Like

I was running it on Intel macOs Monterey.

Just updated to Ventura 13.4 and now I am getting this:

Still no teapot.

My mistake, I was checking it in the DemoRunner, not the stand-alone tutorial. Maybe you should try the DemoRunner to see if that works (it’s in the extras folder)?

1 Like

Teapot rendering in the DemoRunner works. But not for the stand-alone tutorial.


If your second screenshot is from the OpenGL tutorial, I think that’s supposed to be the result. There is no texture mapping applied to the teapot as there is in the DemoRunner example.

1 Like

Both screenshots are from DemoRunner unfortunately. The second screenshot is from OpenGLAppDemo.h.

Great, with that info I was able to repro your issue. I am not on latest Monterrey so I will try again with latest, and if I can repro again, we could perhaps then try and spot the issue. I get these errors in my console in 12.6.3:

**2023-05-29 11:25:36.613620-0700 OpenGLAppTutorial[26663:416562] fopen failed for data file: errno = 2 (No such file or directory)**

**2023-05-29 11:25:36.613739-0700 OpenGLAppTutorial[26663:416562] Errors found! Invalidating cache...**

**2023-05-29 11:25:36.674242-0700 OpenGLAppTutorial[26663:416562] fopen failed for data file: errno = 2 (No such file or directory)**

**2023-05-29 11:25:36.674305-0700 OpenGLAppTutorial[26663:416562] Errors found! Invalidating cache...**

**2023-05-29 11:25:46.541221-0700 OpenGLAppTutorial[26663:416561] Persistent UI failed to open file file:///Users/<username>/Library/Saved%20Application%20State/com.JUCE.OpenGLAppTutorial.savedState/window_7.data: No such file or directory (2)**

I also got this warning in Xcode:
JUCE7_Warning_OpenGL_Tutorial_Monterrey_12.6.3

This warning appears to be a non-issue according to: UI API called from background thread, however @reuk’s fix does not touch the part of the class where this warning is emitted:

Update: I’m whittling it down, the issue persists on latest Monterrey but I don’t have the issue on Catalina with JUCE 7.0.2 and 7.0.5. I’ll try once more with latest JUCE on Ventura.

@TPeters do you have a mac that cannot update beyond Monterrey like a mid-2015 MacBook Pro or similar?

1 Like