[osg-users] how to get the handle of opengl texture that corresponds to a OSG::Texture
Qingjie Zhang
305479421 at qq.com
Sat Sep 12 00:55:03 PDT 2015
Hi Robert,
I fount it! I'm so sorry for my carelessness.
Thank you soooo much!!
Qingjie.
robertosfield wrote:
> Hi Qingjie,
>
>
> This is no longer about the OSG, it's about C++. Your mistake is straight forward C++ issue of not matching the base classes parameters when overidding a method: The Camera::DrawCallback base class is:
>
>
> /** Draw callback for custom operations.*/
> struct OSG_EXPORT DrawCallback : virtual public Object
> {
> DrawCallback() {}
>
> DrawCallback(const DrawCallback&,const CopyOp&) {}
>
> META_Object(osg, DrawCallback);
>
> /** Functor method called by rendering thread. Users will typically override this method to carry tasks such as screen capture.*/
> virtual void operator () (osg::RenderInfo& renderInfo) const;
>
> /** Functor method, provided for backwards compatibility, called by operator() (osg::RenderInfo& renderInfo) method.*/
> virtual void operator () (const osg::Camera& /*camera*/) const {}
> };
>
>
> Please look carefully at your own code to see your mistake.
>
>
> Robert.
>
>
>
>
>
>
> On 10 September 2015 at 04:42, Qingjie Zhang < ()> wrote:
>
> > Hi Robert,
> > To get the handle of opengl texture, I attached a DrawCallback to the main camera, doing like these codes:
> > struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback
> > {
> > virtual void operator()(const osg::RenderInfo &renderInfo)
> > {
> > int contextID = renderInfo.getContextID();
> > GLuint frontTexHandle = m_frontTex->getTextureObject(contextID)->id();
> > GLuint backTexHandle = m_backTex->getTextureObject(contextID)->id();
> > }
> > };
> > camera->setPostDrawCallback(new MyCameraPostDrawCallback);
> >
> > But the function operator() int the callback does not run, I tried setPostDrawCallback() and setFinalDrawCallback(), they were the same.
> > I was thinking that the DrawCallback would run every frame...
> > Can you tell me when the callback runs?
> > And, to get the handle, is it right to attach DrawCallback to camera? If not, can you tell me the detailed method to get the handle?
> >
> > Thank you,
> >
> > Qingjie.
> >
> >
> > robertosfield wrote:
> >
> > > Hi Qingjie,
> > > On 9 September 2015 at 09:27, Qingjie Zhang < ()> wrote:
> > >
> > >
> > > > Do you mean the DrawCallback in the Camera class, which contains
> > > > virtual void operator () (osg::RenderInfo& renderInfo) ? And here I can use the RenderInfo right?
> > > >
> > > >
> > >
> > >
> > > Yes. You can attach draw callbacks to Drawables, StateAtttribute and Camera's.
> > >
> > >
> > >
> > >
> > >
> > > >
> > > > As I know, the following code can get a contextID:
> > > > camera->getGraphicsContext()->getState()->getContextID();
> > > > Is this contextID same as the upper one?
> > > >
> > > >
> > >
> > >
> > > If you only need the contexID then getting it from the graphics context is perfectly fine. What route to take depends on when you need to do your queries.
> > >
> > >
> > > I would add that the TextureObject for each context is only created by the draw thread for each context, so the TextureObject won't exist right away when you create your osg::Texture and assign them to the scene graph.
> > >
> > >
> > >
> > > Robert.
> > >
> > >
> > >
> > > ------------------
> > > Post generated by Mail2Forum
> > >
> >
> >
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=65083#65083 (http://forum.openscenegraph.org/viewtopic.php?p=65083#65083)
> >
> >
> >
> >
> >
> > _______________________________________________
> > 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=65118#65118
More information about the osg-users
mailing list