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!