You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
currently I'm trying to understand how OpenGL contexts, frame buffer objects etc. work and I'm playing around with it a little.
Now, I came up with some questions that when answered would help me a lot to understand things better - and maybe apply some stuff.
So lets say in a scenario I have Irrlicht and in addition another library (lets call it A), that is able to use OpenGL and render something to textures - and I want to combine those two. For instance, if I want A to render something to a texture and then use this texture in Irrlicht to put it on a cube or something. Now here are my questions
1. How can I get the OpenGL ID (or a pointer that i can static_cast to an openGL texture) of an irrlicht texture so that Library A can render to that texture?
2. Do I have to pay attention to the OpenGL context Irrlicht and A are using, so both can access the same textures? Can I tell Irrlicht which context to use when creating textures etc.?
3. Probably both Irrlicht and A have to do the rendering in the same thread as far as I understand. Is my assumption that Irrlicht always does everything within one thread correct, so as long as I create the irrlicht device in the thread that A uses to do the rendering, I'm safe?
Thank you very much, I'm really excited for any answers
1.- Irrlicht textures have a "lock" method, which returns a pointer to the data of the textures, maybe that helps you, somehow, but i guess you need some more elaborate access so you don't have to work directly with this data.
2.- I can't tell but most probably
3.- Irrlicht can be somehow multithreaded, BUT your rendering must be done in the MAIN thread always, as Open GL isn't thread safe (AFAIK)
Irrlicht has a method in the video driver that provides some of the driver's internal variables. getExposedVideoData( ); Take a look, as maybe it is posible for Lib A to use any of that data.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
if you realy need opengl texture ID you can copy COpenGLTexture.h from source reposit and copy them to your projet, and just need to cast any ITexture to COpenGLTexture
and acces to opengl id by getTextureName, but use "lock" methode is more safe if is for data manipulation
but in your sample you doesn't need any opengl id from irrlicht to perform it
just create a derived ISceneNode and in draw() methode:
-set the AbsoluteTransform matrix
-set the material of the cube node by IVideoDriver::setMaterial
-then enable your custom opengl texture by opengl api
-and render the cube manualy by IVideoDriver::drawMeshBuffer
or else yes by COpenGLTexture, add friend attribut to "A", and modify opengl texture id (TextureName) form the external by "A"
but for security "grab()" the texture
If you want 'A' to render to a texture which you then use to texture a cube, you can surely just set the render texture in Irrlicht and then let 'A' render. After this, setting the render target to null would allow you to texture the cube with the old render target.