[osg-users] wrapping an opengl texture to an osg texture
Robert Osfield
robert.osfield at gmail.com
Fri Sep 25 00:35:40 PDT 2015
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 <305479421 at qq.com> 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
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150925/fbdd423f/attachment-0003.htm>
More information about the osg-users
mailing list