setContinuousRepainting(false) ineffective

I have made a very simple project using IntroJucer and an OpenGLAppComponent sub-class (MacOS 10.10).

It seems that a setContinuousRepainting(false) statement does not prevent the render() method from being called.

In fact, if I modify the swap interval ( e.g. setSwapInterval(1000) ), it IS taken into account and the render() method is called at the right pace, despite of the setContinuousRepainting(false) statement being used. Shouldn't it be called only if I use a triggerRepaint() call ?

Maybe I am missing something ?

Can you also please confirm that the triggerRepaint() method asynchronously calls the render() method (not the paint() method) ?


I don't understand how that could happen.. If you look at juce_OpenGLContext.cpp line 377, it waits indefinitely if continuous repainting is disabled.

Can you also please confirm that the triggerRepaint() method asynchronously calls the render() method (not the paint() method) ?

Yes, that's right.

Well it does go to the wait(-1) when stating setContinuousRepainting(false), but that does not prevent it from drawing the new shader code.

Clearly there is something I don't understand here. The following code calls render method twice every second or so. If I change the parameter for setSwapInterval to, say, 200, render() is called every 2 seconds or so.

Why is render() called ? Why does setSwapInterval have any effect since I have setContinuousRepainting(false) ? I tried to look at your code but got lost...

class MainContentComponent   : public OpenGLAppComponent,Timer
        setSize (800, 600);


    void initialise() override
        shader = nullptr;
    void timerCallback()
// render() should not be called since we comment line below out and because of setContinuousRepainting(false) above
//        openGLContext.triggerRepaint();   // this calls render() method (not paint()...)

    void shutdown() override

    void render() override
        static int count = 0;

    void paint (Graphics& g) override

    void resized() override


    ScopedPointer<OpenGLGraphicsContextCustomShader> shader;


If your timer keeps calling repaint() then of course it'll keep rendering.. (?)

OK. This is what I had not understood. (Sorry the code is not that obvious...)

So, to make sure:

- triggerRepaint calls render and not paint (nor repaint)

- repaint calls render and paint

- setContinuousRepainting(true) generates continuous calls to render (not paint nor repaint)

- as long as repaint is not explicitely called, the shader will not display anything in the component (for instance if a new object has been assigned to the shader in the meantime, the new shader code will not be executed)

Is that correct ?

Thanks for your time.

Yes, that sounds about right!

Hi guys, let me write here about the same problem with the latest JUCE version.

Again, setContinuousRepainting(false) is ineffective even though I do not call repaint() in my code.

I have tested with OpenGLDemo and replaced the corresponding line to openGLContext.setContinuousRepainting (false); but it keeps calling renderOpenGL() and updates the animation.

I am struggling with this issue because otherwise, my software always running the rendering task and consuming the CPU power.

Is there any idea?


Small update : I found that this issue happens in the latest JUCE version.
When I replaced the current juce_OpenGLContext.cpp to the previous version, then the problem solved.
Could anybody check and fix the code so that we can use setContinuousRepainting(false) is effective again?

Thank you!

This has been fixed in 270237b - thanks for reporting!