<div dir="ltr"><div><div>Hi Qingjie,<br><br></div>I haven't experiment with CUDA so can't comment on the specifics.  The best route is probably to see anyone has published an OSG/CUDA integration example.<br><br></div>Robert.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 25 September 2015 at 13:04, 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 Robert,<br>
<br>
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.<br>
<br>
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.<br>
<br>
Thank you!<br>
<br>
Qingjie.<br>
<span class=""><br>
robertosfield wrote:<br>
> HI Qingjie,<br>
><br>
><br>
> 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>
><br>
> Robert.<br>
><br>
><br>
</span><div><div class="h5">> On 25 September 2015 at 07:27, Qingjie Zhang < ()> wrote:<br>
><br>
> > 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>
</div></div>> > <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> (<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>
> >  ()<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> (<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>
> ><br>
><br>
><br>
>  ------------------<br>
> Post generated by Mail2Forum<br>
<span class=""><br>
<br>
------------------<br>
Read this topic online here:<br>
</span><a href="http://forum.openscenegraph.org/viewtopic.php?p=65215#65215" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=65215#65215</a><br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br></div>