I’m trying to use JUCE to render a certain component to an OpenGL texture and to send it through Spout to another program. If it’s possible this would have to be offscreen.
I tried several things but couldn’t find a way to do this. What would be the correct way to do this?
You’d need to create an Image with the OpenGLImageType, then draw into it as usual with a Graphics object. Then you can grab its frame buffer and use that.
You will need an active GL context when you do this, though, so will need to actually have an OpenGLContext and do your rendering in its callback.
So I want to create a custom component that shows certain information. This component has to be sent through Spout (spout is a library to share graphics between programs). So I want to send this component to Resolume Arena to map the information in this VJ program.
So I want to know how to know how I get the OpenGL texture from this component to give it to the spout library to send this texture to the other program so I can use it in this. But I don’t know enough from the internals from JUCE and openGL to know where I should do this. Where should I do the paintEntireComponent, in the paint() function of the component?
What you want is probably the OpenGL handle of the Texture Juce renders in so you can share it using Spout. I don’t know the specifics of the Juce OpenGL rendering but what you could do as well is render to an Image and convert that to a texture yourself. Using the BitmapData of the Juce Image that’s actually quite simple. But of course getting the Texure handle directly from Juce would be ideal. I guess Juce uses a render to texture mechanism. Let me know how you get on with this.
I’ll dive deeper in the internal JUCE render engine. Another option is to do all the rendering directly in OpenGL, but I prefer to use the easy JUCE components to show stuff because I’m not an OpenGL expert.
Rendering to a image and then converting to a texture seems like (correct me if I’m wrong) going from GPU data --> CPU data --> GPU data and seems indeed a bit unnecesarry.