<div dir="ltr"><div><div>HI Qingjie,<br><br></div>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?<br><br></div>Robert.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 25 September 2015 at 07:27, Qingjie Zhang <span dir="ltr"><<a href="mailto:305479421@qq.com" target="_blank">305479421@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I have an opengl texture(GLuint), I'd like to wrap it to an osg::Texture2D. Is there some way to do this?<br>
<br>
Actually, I got the GLuint in this way:<br>
<br>
Code:<br>
<br>
struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback<br>
{<br>
    virtual void operator()(osg::RenderInfo &renderInfo) const<br>
        {<br>
                int contextID = renderInfo.getContextID();<br>
                GLuint handle= m_frontTex->getTextureObject(contextID)->id();<br>
<br>
        }<br>
}<br>
<br>
<br>
<br>
<br>
I've googled and searched in this forum, finding maybe a way to do this by:<br>
<br>
Code:<br>
<br>
osg::Texture2D *_texture = new osg::Texture2D;<br>
osg::Texture::TextureObject *textureObject = new osg::Texture::TextureObject(_texture, handle, GL_TEXTURE_2D);<br>
                textureObject->setAllocated();<br>
                _texture->setTextureObject(renderInfo.getContextID(), textureObject);<br>
                osg::State *state = renderInfo.getState();<br>
                unsigned int _textureStage = 0;<br>
<br>
                state->setActiveTextureUnit(_textureStage);<br>
                _texture->apply(*state);<br>
                state->haveAppliedTextureAttribute(_textureStage, _texture);<br>
<br>
<br>
<br>
But I don't know what the "_textureStage" should be, I tried "0", but "state->setActiveTextureUnit(_textureStage);" returns false.<br>
<br>
Is this the right way to achieve my goal? If not, how should I do?<br>
...<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Qingjie<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=65205#65205" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=65205#65205</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>