OpenGLRenderer in tabComponent


#1

 

Hey all -

I just noticed that if I drop an OpenGLRenderer into one of the tabs of a tabbed component, it gets all screwed up.

I'm guessing this is something silly like the context gets set inactive when visibility changes?

Pretty new to openGL, so I'm not clear on some of the implications of heavyweight windows I guess.

Anyhow, any help is appreciated, thanks!


#2

 

 

Ok - I get this.  That is a heavyweight component inside a lightweight component.  

I can add other juce components within the openGLRenderer no problem, but other components that are lightweight can't overlap the GLRenderer.  Got it.  

The usual thing, then, is to attach the topLevelWindow to a GL context, and then everything is within that one heavyweight window and can be moved around as usual.  

Except .... then I can't seem to get a canvas.  How can I then run openGL commands inside some portion of the window?  Is there a way to get a sub-canvas?

Or can I have multiple GL Contexts in one project?  It would seem no, but maybe I am doing something wrong?

 

*sigh* getting there : )

 


#3

Or can I have multiple GL Contexts in one project?  It would seem no, but maybe I am doing something wrong?

This is on my to-do list - i.e. having the whole window running a GL rendering engine and allowing multiple GL renderers to work within different sub-components.


#4

 

Aha!  Yeah, that would be amazing.  

BTW - does openGL work in plugins yet?  I know that was an issue a while back, I have a couple plugins waiting in the wings that I don't really want to release until I can add GL to them, but last I checked it was an impossible.

I guess it might be a related issue, since you can have multiple instances of the plugin UI, but not multiple openGL canvases?


#5

 

 

Also, took me forever to figure out that I needed to do ...

 

glDisable(GL_CULL_FACE); 

 

Without it, no 2D stuff would work properly.  Not sure what's going on there.


#6

What is the status on this?

This issue is highly relevant to our company. As one part of our user interface we have free-floating window-like components. One of these contains a panel with a 3D model. The component containing the 3D surface is rendered above any other GUI elements, including the main window title, menus, etc.

We've tried fixing by manually setting the glScissor region (ineffectual -- it seems juce pushes all GL flags before rendering?), setting top-level component to a OpenGLAppComponent, manipulating the openGlContext, etc. Currently we're trying to render an image from the GL framebuffer to an off-screen surface but we can't stop the component from rendering to the screen. In other words, we're sort of stuck.

Any advancements here or even a status update would be much appreciated!

Yours,

Michael


#7

Sorry, haven't had chance to do my changes to allow multiple embedded GL contexts yet.. However the it's actually something you could implement manually. Essentially the plan is pretty simple:

- You attach a GL context to the entire window

- Each sub-component that wants to do some GL would be derived from a special type of component. This component would have an OpenGLImage, and its rendering callback would select this image as the GL rendering target. Then the component's paint() method would draw this image, so that it gets composited normally with all the regular 2D stuff.

- During the top-level window's renderOpenGL() callback, it'd iterate any of these special components that are visible, and call their renderOpenGL() calls.

..so not rocket-science, and not even something that would need deep changes to any existing juce classes, but just haven't had a chance to do it yet!


#8

I made an attempt using the solution proposed above. What I currently have is the following:

 - Window has a GL context attached and implements the methods in OpenGLRenderer

 - Window propagates renderOpenGL calls to the sub-components which needs it

 - Sub-components renders to a framebuffer obtained from an Image (w. OpenGLImageType) in the propagated renderOpenGL-calls

 - Sub-components draws the rendered image in their paint-methods

 

This is a step in the right direction. However, I've run into the following issues:

 - When sub-components draws the rendered image, the result is pretty much a pile of semi-random pixels. However, if I write the rendered image to disk (through PNGImageFormat), the resulting image looks intact

 - The rendered results obtained using this method differs from the results obtained when a sub-component creates its own GLContext. Insides of objects are rendered, for example. Are you aware of any limitations in using this method? I'm rendering a 3D-scene, if that gives any clues

 - I'd like to render on demand rather than performing continuous rendering. Any suggestions on how to trigger the renderOpenGL-calls from a sub-component?

 


#9

Hard to guess what might be going wrong there..

You can trigger a render on demand with OpenGLContext::triggerRepaint()