HI Qingjie, If you are getting the GL texture handle id from an OSG TextureObject it'll already be associated with a osg::Texture i.e. m_frontTex why not just reuse this?
Robert. On 25 September 2015 at 07:27, Qingjie Zhang <[email protected]> wrote: > Hi, > I have an opengl texture(GLuint), I'd like to wrap it to an > osg::Texture2D. Is there some way to do this? > > Actually, I got the GLuint in this way: > > Code: > > struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback > { > virtual void operator()(osg::RenderInfo &renderInfo) const > { > int contextID = renderInfo.getContextID(); > GLuint handle= > m_frontTex->getTextureObject(contextID)->id(); > > } > } > > > > > I've googled and searched in this forum, finding maybe a way to do this by: > > Code: > > osg::Texture2D *_texture = new osg::Texture2D; > osg::Texture::TextureObject *textureObject = new > osg::Texture::TextureObject(_texture, handle, GL_TEXTURE_2D); > textureObject->setAllocated(); > _texture->setTextureObject(renderInfo.getContextID(), > textureObject); > osg::State *state = renderInfo.getState(); > unsigned int _textureStage = 0; > > state->setActiveTextureUnit(_textureStage); > _texture->apply(*state); > state->haveAppliedTextureAttribute(_textureStage, > _texture); > > > > But I don't know what the "_textureStage" should be, I tried "0", but > "state->setActiveTextureUnit(_textureStage);" returns false. > > Is this the right way to achieve my goal? If not, how should I do? > ... > > Thank you! > > Cheers, > Qingjie > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=65205#65205 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

