Hello Carsten,

I have tried to come up with a simple helper class wrapping the creation 
process of a framebuffer object. I would like to cover the following 
scenarios

one color buffer either as RenderBuffer or as TextureBuffer
a depth buffer  either as RenderBuffer or as TextureBuffer
a stencil buffer  either as RenderBuffer or as TextureBuffer

I got compiler errors and I'm not sure about the texture part  for a depth / 
stencil scenario. I have not understand how I should setup the 
GL_DEPTH24_STENCIL8 scenario. Additionally, the GL_DEPTH24_STENCIL8 symbol 
is not defined. Should it be added to OSGGLEXT.h?

My code...

SimpleFBO::SimpleFBO(
    bool depth,         // provide depth buffer
    bool stencil,       // provide stencil buffer
    bool color_texture, // color buffer as texture
    bool depth_stencil_texture, // depth/stencil buffer as texture
    UInt32 width,
    UInt32 height)
: _fbo(FrameBufferObject::create())
{
    if (color_texture) {
        TextureBufferUnrecPtr texBuf = genTextureBuffer(width, height);
        _fbo->setColorAttachment(texBuf, 0);
    } else {
        RenderBufferUnrecPtr renBuf = RenderBuffer::create();
        _fbo->setColorAttachment(renBuf, 0);
    }
    _fbo->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT);

    if (depth && !stencil) {    // only depth buffer
        if (depth_stencil_texture) {
            TextureBufferUnrecPtr buffer = genTextureBuffer(width, height);
            buffer->setInternalFormat(GL_DEPTH_COMPONENT24);    // error: 
interface doesn't exist
            _fbo->setDepthAttachment(buffer);
        } else {
            RenderBufferUnrecPtr buffer = OSG::RenderBuffer::create();
            buffer->setInternalFormat(GL_DEPTH_COMPONENT24);
            _fbo->setDepthAttachment(buffer);
        }
    } else
    if (depth && stencil) {    // depth buffer + stencil buffer
        if (depth_stencil_texture) {
            TextureBufferUnrecPtr buffer = genTextureBuffer(width, height);
            buffer->setInternalFormat(GL_DEPTH24_STENCIL8);     // error: 
interface doesn't exist
            _fbo->setDepthAttachment(buffer);                   // error ?
            _fbo->setStencilAttachment(buffer);
        } else {
            RenderBufferUnrecPtr buffer = OSG::RenderBuffer::create();
            buffer->setInternalFormat(GL_DEPTH24_STENCIL8);     // error: 
symbol unknown
            _fbo->setDepthAttachment(buffer);
            _fbo->setStencilAttachment(buffer);
        }
    }
    if (!depth && stencil) {    // no depth buffer but stencil buffer
        ??? is this possible
   }

    _fbo->setWidth (width );
    _fbo->setHeight(height);
}

osg::TextureBufferTransitPtr SimpleFBO::genTextureBuffer(osg::UInt32 width, 
osg::UInt32 height)
{
    ImageUnrecPtr           texImg = Image::create();
    TextureObjChunkUnrecPtr texObj = TextureObjChunk::create();
    TextureBufferUnrecPtr   texBuf = TextureBuffer::create();

    texImg->set(Image::OSG_RGB_PF, width, height);
    texObj->setImage(texImg);
    texBuf->setTexture(texObj);

    return TextureBufferTransitPtr(texBuf);
}

Gerrit has provided this line of GL code in another thread:

http://www.mail-archive.com/[email protected]/msg13160.html

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT,
             512, 512, 0, GL_DEPTH_STENCIL_EXT,
             GL_UNSIGNED_INT_24_8_EXT, NULL);

What is the place I have to provide the GL_DEPTH24_STENCIL8_EXT and 
GL_DEPTH_STENCIL_EXT parameters in my setup?

Could you give me an additional push...

Best,
Johannes




------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to