OpenGLComponent question + feature request

Hi, can anyone show an example of using OpenGLComponent and doing rendering from a different thread?

According to the OpenGLComponent documentation there is a function renderAndSwapBuffers() which has the ability to “decouple the rendering from the paint callback and render with a different thread.”, but i can’t see how (i’m a bit newbie with juce)

Also this post is a feature request to Jules. I think that there should be a flag for enabling threaded OpenGL rendering since there isn’t out there any gui library which supports this type of behaviour, and it is very handy if you want to do proper time-based animation.

You just run another thread that does the drawing, and make it call renderAndSwapBuffers() when it’s done. Not sure what you mean about adding a flag to do that (?)

Thanks for the reply.
You mean like this:

myThread::entryPoint() { while(!stopRenderBecauseItsTimeToQuit) { glCanvas.renderAndSwapBuffers(); } }

About the request, what I mean is flag in the contructor of the class OpenGLComponent that when is enabled it opens a thread and calls render() all the time, along with a set of functions like pause() and kill() for controlling this new thread.

Yes, that’s the general idea. Hmm, I guess I could add a built-in thread to do it…

A built-in thread! That would be great! :smiley: