OpenGLComponent in the Juce Demo


#1

A recent Git update says it supports threaded component updates now. But when I break into the debugger, it’s being called from a timer, not a thread.

Maybe the wrapping in a parent broke the threading behavior?

Or maybe the entire embedded component is being rendered on the main thread on purpose? In which case there’s no threaded activity really - the wrapper doesn’t draw anything.

Bruce


#2

Ah, I see. Every demo but the OpenGL demo uses a threaded OpenGL component if the OpenGL renderer is active.

If the OpenGLDemo is selected, the OpenGLRenderer is disabled - the OpenGLDemo then runs in the main thread.

OK, so if the demo itself is set to multi-thread, the top components flicker like crazy unless the component is being altered (dragging the mouse around, for instance).

And I guess when a threaded OpenGLComponent is active, you can’t use the OpenGLRenderer?

Bruce


#3

OK.

If I prevent the OpenGLRenderer from being disabled when the OpenGL demo is run, and I put the demo onto a thread, it works perfectly - no flicker, or maybe a very occasional beat - sliders disappear for a frame or too.

Awesome work on the OpenGL stuff Jules! If you weren’t an expert before, you are now. :smiley:

Bruce


#4

Having thought about the awesome implications, I have a feature or clarification request!

Let’s say I have an OpenGLComponent. It may or may not be in an OpenGLRenderer, I suppose. Inside that component are some ‘objects’. Currently I manage them. I would like it better if they were components, so I can use hierarchy, messages etc. but they need to render every single GL frame, i.e. they need to draw in renderGL(), not in paint().

Is that currently feasible? Or a feature request - components that have to be in an OpenGLComponent.

There’s a number of issues down the road, obviously - picking and the effect of OpenGL on visibility and position, but let’s assume the component has a main ‘bounding box’ - the component’s position - and clicks etc are based on that.

Bruce


Components in OpenGL thread
#5

Yeah, that’s all stuff that I’ll be working on - the idea is that you’d probably make your top-level component an OpenGLComponent, and then in any sub-component, I’ll figure out a way that you can draw GL. (Perhaps by adding a Component::renderOpenGL method that any component could override, but I haven’t quite decided yet)


Components in OpenGL thread