Hi Art,
I use
_image->readPixels(int(viewport->x()),int(viewport->y()),int(viewport->width()),int(viewport->height()),
GL_RGBA, GL_UNSIGNED_BYTE);
No display setting was set, so I made it
osg::DisplaySettings* ds = new osg::DisplaySettings();
ds->setMinimumNumAlphaBits(8);
view->setDisplaySettings(ds);
No changes...
FBO with RTT sounds like a great solution but I'm afraid I don't have enough
time to have this week, and it will be too late.
So, I try the data modification of the image, but the write file return me
an error.
I do that :
static osg::ref_ptr<osg::Image> changeBackground(osg::Image* img)
{
osg::ref_ptr<osg::Image> result = new osg::Image(*img,
osg::CopyOp::DEEP_COPY_ALL);
if(!result->valid())
return NULL;
if(result->getPixelSizeInBits()/8 != 4)
return NULL;
unsigned char* data = (unsigned
char*)calloc(result->s()*result->t()*4, sizeof(unsigned char));
long n = 0;
for(long i = 0; i < (result->s()*result->t()) ; i++)
{
data[n] = result->data()[n];
data[n+1] = result->data()[n+1];
data[n+2] = result->data()[n+2];
data[n+3] = 1.0;
n+=4;
}
result->allocateImage(result->s(), result->t(), result->r(),
result->getPixelFormat(), result->getDataType());
result->setImage(result->s(), result->t(), result->r(),
result->getInternalTextureFormat(), result->getPixelFormat(),
result->getDataType(), data, result->getAllocationMode());
return result;
}
Do you see anything strange in it ? because Image seems to be unValid...
Thanks Art, and anyone who can give me some advice/help
Regards,
Vincent.
2009/2/23 Art Tevs <[email protected]>
> Hi Vincent,
>
> ah ok, you are not using RTT features. I would suggest to do so, because
> otherwise pixel which are outside of your viewport are undefined (in most
> case you will get the window boundaries too ;). With glReadPixels it can
> happen htat you even capture the mouse pointer, which is sometime not the
> thing you want, I suppose.
>
> Ok, I suppose you then have a proper parameters set to
> image->readPixels(..., GL_RGBA, ...); ?
> If you capture your pixel information directly from the framebuffer then
> you have to setup the framebuffer in the proper way. It should support alpha
> values too. Check if you setup the display settings properly, here
> osgViewer::View::getDisplaySettings(), you have to setup proper amount of
> alpha bits (i.e. 8).
>
> In general, I really propose to use FBO with RTT, otherwise you could even
> capture other windows which overlap with yours if you capture pixels
> directly from the framebuffer.
>
> cheers,
> art
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=7232#7232
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org