Mixing OpenGLContexts components and 'Regular' components

Hey there,

I just have a quick question about layering OpenGLContexts with ‘normal’ components (by normal I just mean non-openGL drawing components).

In my previous use of OpenGLContexts, I would basically attach it to a parent component that was the GLRenderer, do my openGL drawing, and then add ‘normal’ child components to the parent component, and this would work fine. The normal child components would draw on top of the parent component.

This time around, I’m trying to do things a little more advanced, where I have a normal parent component, and then individual child components that have their own GLcontext and are their own renderer, as well as other normal child components.

This seems to work fine, however whenever a normal child component overlaps/overlays on a GLcontext, the GLContext always sits on top. Again, previously this did not happen when the parent component was the GLRenderer and attached to the context, but now that they are seperate components, issues arise.

I assume there’s something simple I’m missing, or that is just the nature of GLContexts and it can’t be done. Should the parent component just be the renderer and the child components just have the context? Any input appreciated!

The OpenGL context is actually floating a window in front of the juce window, so think of each context as it’s own window floating in front.

hmmm…

So I guess then if the parent is the renderer and the context is attached to it, Juce probably does something where it merges the output of the the juce component with the GLContext output. But if they are seperate contexts and renderers then the GL components would always be on top ?

Pretty much. If a context is told to render child components, juce renders the components on the cpu into a frame buffer, which then gets passed to down through the pipeline. Locks are involved, which is why using any kind of juce paint routine with a OpenGL context can degrade performance.

Okay. So if this is true, do you know how I would draw multiple components with different shader drawings going on? If the parent component does all the rendering, I suppose each child component could get provided the context and then switch out its own shader/uniforms/etc… and call draw. And each component adjusts the viewport to its bounds?

This doesn’t sound terrible but not great lol.