Hi Robert,

I'm trying to do something with the "m_frontTex" in CUDA, so I get the GLuint 
and write some values in it according to a CUDA_Opengl_interp example.

But I found there's no change in the texture after CUDA processing. So I'm 
confused if the texture will update automatically when the "GLuint" changes, if 
true, there must be something wrong in my CUDA processing.

Thank you!

Qingjie.

robertosfield wrote:
> 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 < ()> 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 
> > (http://forum.openscenegraph.org/viewtopic.php?p=65205#65205)
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  ------------------
> Post generated by Mail2Forum


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65215#65215





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to