You may be right...I can't manage to reproduce the bug with a simple test.
May this is cause by my QT5 integration...
.. a strange thing to have multiples GL_TEXTURE_BINDING_* on the same active 
texture unit...



robertosfield wrote:
> Hi Julien,
> 
> 
> My best guess is that your callback is being called when OpenGL is not set up 
> fully to apply the texture your are applying - effectively you are apply a 
> texture to an indeterminate texture unit with an indeterminate enabling of 
> modes, so in effect you'll be just inheriting whatever has been applied 
> before rather than exactly what you want.
> 
> 
> The use of node is also pretty odd way to manage callbacks that are attached 
> at the viewer level.  Your code segment leaves us to guess lots of what might 
> or might not be happening in the rest of your app, and what you might be 
> trying to do with the code.
> 
> 
> Could you take a step back and explain from a high level you are attempting 
> to do in your application and then others can suggest the appropriate way to 
> tackle such functionality.
> 
> 
> Robert.
> 
> 
> 
> 
> 
> On 12 November 2014 17:22, Julien Valentin < ()> wrote:
> 
> > Hi,
> > Hi,
> > I just implement a kind of dirty texture read back node and ran into a 
> > weird problem:
> > As you can notice in the attached code, I had a problem with 
> > Image::readImageFromCurrentTexture.
> > I would like to read back a 2D texture but a 1D texture is binded too.
> > The 1D->2d->3d->cubemap priority scheme in osg::Image
> > (   GLenum textureMode = binding1D ? GL_TEXTURE_1D : binding2D ? 
> > GL_TEXTURE_2D : binding3D ? GL_TEXTURE_3D : binding2DArray ? 
> > GL_TEXTURE_2D_ARRAY_EXT : 0;
> >  )
> > forced me to disable the 1D binding explicitly.
> > 
> > My opinion is that a priority scheme is not enough to decide which texture 
> > binding to read-back (all texture binding mode can be activated at the same 
> > time, am i right?)
> > 
> > So,my proposal would be to make textureMode a parameter of 
> > readImageFromCurrentTexture.
> > 
> > Further, I don't think my node removal code is thread safe so don't pay 
> > attention to it (its work for my signl_threaded test)
> > 
> > Code:
> > 
> > class ImageReadBackNode:public osg::Group{
> > 
> > void ImageReadBackNode::setTexture(osg::Texture*tex){
> >         //assert(tex->getImage());
> >         class ImageReadBackNodeCallback : public osg::Camera::DrawCallback
> >         {
> >                 osg::Texture *_texture; osg::Node *_n;
> >         public:
> >                 ImageReadBackNodeCallback(osg::Texture *texture, 
> > osg::Node*toremove) :_texture(texture), _n(toremove){ };
> > 
> >                 virtual void operator () (osg::RenderInfo& renderInfo) const
> >                 {
> >                         // get OpenGL driver to create texture from image.
> >                         _texture->apply(*renderInfo.getState());
> > ///BAD
> >  glBindTexture(GL_TEXTURE_1D, 0);
> >                         glDisable(GL_TEXTURE_1D);
> >                         
> > _texture->getImage()->readImageFromCurrentTexture(renderInfo.getContextID(),true,_texture->getSourceType());
> > 
> >                         glEnable(GL_TEXTURE_1D);
> > 
> > 
> > ///Node self removal in drawthread (dirty but seams to works:/ ..) 
> > THREADSAFE?
> >                         std::list<osg::Group*> gr;
> >                         for (int i = 0; i < _n->getNumParents(); 
> > i++)gr.push_back((_n->getParent(i)));
> >                         for (std::list<osg::Group*>::iterator it = 
> > gr.begin(); it != gr.end(); it++)
> >                                 (*it)->removeChild(_n);
> > 
> >                 }
> >         };
> >         osg::ref_ptr<osg::Camera > cam = new osg::Camera();
> >         cam->setFinalDrawCallback(new ImageReadBackNodeCallback(tex,this));
> >                 this->addChild(cam);
> > 
> > }
> > };
> > 
> > 
> > 
> > Thank you!
> > Any advice would be welcome
> > Cheers,
> > Julien
> > 
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=61597#61597 
> > (http://forum.openscenegraph.org/viewtopic.php?p=61597#61597)
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > 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=61601#61601





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

Reply via email to