Hello Marco,
I had almost exactly the same situation as you, the third party library that was involved was Qt, another team was using Qt to draw into an OpenGL Texture (generated with plain old glGenTextures), created in their own QOpenGLContext. The id was then passed to my OSG-based library and I would use that texture to map it onto a 3d object.
The solution I made was fairly straightforward, I don't know if it is the "correct" way to do it, but it worked/works. Anyway, basically just derive a class from osg::Texture2D which just has a member of the texture id, and then bind that in an override of the apply() method:
<code>
class Texture2DRef : public osg::Texture2D
{
public:
explicit Texture2DRef( GLuint textureId = ~0 ) : osg::Texture2D(), mTextureId(textureId() {}
Texture2DRef( Texture2DRef const & orig osg::CopyOp const & op = ... ) { ... }
META_StateAttribute( ... )
get/setTextureId(...) { ... }
void apply( osg::State & state ) const override
{
if ( mTexture == ~0 ) {
return;
}
glBindTexture( GL_TEXTURE_2D, mTextureId );
}
private:
GLuint mTextureId;
};
</code>
TBH, not sure if what I'm doing here is legal OpenGL. The logic for creating the (shared) contexts between Qt and OSG was developed by the end customer/integrator and complicated, but there was no guarantee that the contexts were shared or the same. I'm curious if anyone out there knows if this is a valid solution or possibly the case of different contexts was just never tested :(
HTH,
Chris