How to unlock the fps when using OpenGLAppComponent

I remembered when I set openGLContext.setSwapInterval(0) in void initialise() override; on windows , then fps will be as fast as it can.
But I on my mac catalina version 10.15.5(19f10) , juce version v6.0.4 it wouldn’t work and will always be 60fps.

Is there anyone could tell me what causes the fps limitation? Thanks.

I test the fps with the OpenglAppDemo.h

in initialise I add the code openGLContext.setSwapInterval(0);
the whole function looks like

    void initialise() override

then I have a fps caculation class like :

class FPS
    int fps = 0;

        lastTime = Time::getMillisecondCounter();
    void incFrameCount()
        if (Time::getMillisecondCounter() - lastTime > 1000)
            fps = frameCount;
            frameCount = 0;
            lastTime = Time::getMillisecondCounter();


    juce::uint32 lastTime; // ms
    int frameCount{ 0 };

then declare a variable FPS _fps ; in OpenGLAppDemo class.
then in render function I just printout the fps like this:

    DBG("SwapInterval :" << openGLContext.getSwapInterval() << " fps:" << _fps.fps);

the whole code is at

if you run the code , the output will be something like this :

SwapInterval :0 fps:61

SwapInterval :0 fps:61

SwapInterval :0 fps:61

SwapInterval :0 fps:61

SwapInterval :0 fps:61

It would be great if someone can point out how to unlock the fps,

I found the reason is that opengl rendering is using CVDisplayLink things to Synchronize with the Screen Refresh Rate. That’s the reason why fps is always around 60fps.

But I still do not know how to unlock the fps only for my component.
So my simple fix would be comment out the code repaintEvent.wait (-1);

           #if JUCE_MAC
            if (cvDisplayLinkWrapper != nullptr)
           //     repaintEvent.wait (-1);

Is there any more appropriate way to unlock fps for specific opengl component ?

1 Like