Robert,

I totaly agree that high level FBO code could be modified to avoid potential glitches with doubling resources.

But on low level discussion, I also think that indirect modification of internalTextureFormat in readPixels may bring trouble for pieces of code relying on Image::getInternalTextureFormat(). I did a quick scan and these code includes initialization of FBO Renderbuffers and initilization of Textures (obviously).

As far as I understand Image::setInternalTextureFormat is created to let programer decide what will be internal format of the texture and renderbuffer created from this image. Right ?

So now imagine this case. I want to create texture with RGBA32F internal format from an Image. I create image and set its internalTextureFormat to RGBA32. To fill image data I call readPixels from frame buffer. Then I create Texture from this image and surpirisngly end up with RGBA ubyte Texture. So I wanted RGBA32F texture but got RGBA. I don't think this is OK.

Cheers,
Wojtek

Hi Wojtek,

I believe the Image::readPixels and Image::allocateImage are valid,
changes these because of some high level behaviour is going amiss due
to it relying upon a parameter that is modified on the fly suggest to
me that perhaps the high level code is at fault i.e. the Camera
attachments/FBO setup perhaps needs to be refactored slightly.

Robert.

On Thu, Jun 26, 2008 at 9:33 PM, Wojciech Lewandowski
<[EMAIL PROTECTED]> wrote:

Hi Robert,

I am not sure if this is a bug, but in my opinion Image::allocateImage
should not change internalTextureFormat or at least Image::readPixels
should
record and restore internalFromat after calling allocateImage.

I don't follow, are we talking about the the format in osg::Image or
the texture?

Sorry for being imprecise. All the time I was talking about
osg::Image::_internalTextureFormat member.

I may submit a fix but I am not sure what is desired course of action.
Should I remove the line changing it from Image::allocateImage or rather
modify Image::readPixels to preserve it from modification when
Image::allocateImage is called ? See the bits of code that could be
affected, below.


osg::Image::allocateImage is called from Image::readPixels, Line 608
[...]
void Image::readPixels(int x,int y,int width,int height,
                       GLenum format,GLenum type)
{
    allocateImage(width,height,1,format,type);

    glPixelStorei(GL_PACK_ALIGNMENT,_packing);

    glReadPixels(x,y,width,height,format,type,_data);
}
[...]

osg::Image::_internalTextureFormat modified in:
Image.cpp, Image::allocateImage( int s,int t,int r,  GLenum format,GLenum
type, int packing), Line 556
[...]
    if (_data)
    {
        _s = s;
        _t = t;
        _r = r;
        _pixelFormat = format;
        _dataType = type;
        _packing = packing;
        _internalTextureFormat = format;
    }
[...]


Image::_internalTextureFormat is used (through getInternalTextureFormat
accessor method) to select Renderbuffer format:
FrameBufferObject.cpp,
FrameBufferAttachment::FrameBufferAttachment(Camera::Attachment&
attachment), Line 365:
[...]
    osg::Image* image = attachment._image.get();
    if (image)
    {
        if (image->s()>0 && image->t()>0)
        {
GLenum format = attachment._image->getInternalTextureFormat();
            if (format == 0)
                format = attachment._internalFormat;
            _ximpl = new Pimpl(Pimpl::RENDERBUFFER);
_ximpl->renderbufferTarget = new osg::RenderBuffer(image->s(),
image->t(), format);
[...]


Cheers,

Wojtek



_______________________________________________
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

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

Reply via email to