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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org