fred_em wrote:
> Hi,
> 
> I am confused about how to use PBOs in OSG. I browsed the forum quite a bit 
> but still can't make my code work.
> 
> 1) GPU -> CPU pixel transfers
> 
> As I understand it, an osg::Image with an osg::PixelBufferObject cannot be 
> used (yet) to read FBO contents. I have actually checked that and could see 
> that glReadPixels() still uses a client-side memory pointer. I believe this 
> scenario is not supported yet. Not a big deal.
> 
> I understand it is possible to do this manually and follow for instance what 
> is done in the osgscreencapture sample. This sample doesn't make use of 
> osg::PixelBufferObject, and instead manually creates a GL PBO, manually calls 
> glReadBuffer with a bound pixel buffer object.
> 
> 2) CPU -> GPU pixel transfers
> 
> I gave this a go but cannot make it work yet. To see if the PBO is 
> effectively used this time in my GL tracer I look at a current bound PBO and 
> the last parameter of glTexImage2D, which would reflect an offset and not a 
> client side pointer.
> 
> My code to create my texture, image and PBO is the following:
> 
> 
> Code:
> Image *image = osgDB:readImageFile(filePath);
> 
> // PBO image binding method 1 - this line has no effect for me
> PixelBufferObject *pbo = new PixelBufferObject(image);
> 
> // PBO image binding method 2 - I get a crash in 
> BufferObject::computeRequiredBufferSize here
> image->setPixelBufferObject(new PixelBufferObject());
> 
> Texture2D *texture = new Texture2D(image);
> geode->getOrCreateStateSet()->setTextureAttributeAndMode(0, texture, 
> StateSet::ON);
> 
> 
> 
> 
> I don't see any PBO created in the GL trace, and glTexImage2D still reads 
> image data off a client side pointer.
> 
> What I am doing wrong?
> 
> Cheers,
> Fred

This looks like a bug to me. The following code works:


> Image *image = new Image();
> image->allocate(256, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1);
> image->setPixelBufferObject(new PixelBufferObject(image));
> Texture2D *texture = new Texture2D();
> texture->setImage(image);
> 

The following doesn't work:


> Image *image = osgDB::readImageFile(...);
> image->setPixelBufferObject(new PixelBufferObject(image));
> // I've tried image->dirty(); here, too
> Texture2D *texture = new Texture2D();
> texture->setImage(image);
> 

In the second case, a GL tracer shows that glGenBuffers(1, ...); is called, but 
nothing is done beyond that. 

Long story short, if you create an Image with osgDB::readImageFile(), things 
don't work. Surprisingly enough, dirty() makes no difference.

Cheers,
Fred

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=34534#34534





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to