Hello,
after some further investigations I have come up with the following...
SimpleFBO::SimpleFBO(
bool depth,
bool stencil,
bool color_texture,
bool depth_stencil_texture,
UInt32 width,
UInt32 height,
bool main_mem_image)
: _fbo(FrameBufferObject::create())
{
if (color_texture) {
ImageUnrecPtr texImg = Image::create();
TextureObjChunkUnrecPtr texObj = TextureObjChunk::create();
TextureBufferUnrecPtr texBuf = TextureBuffer::create();
texImg->set(Image::OSG_RGB_PF,
width, height, 1, 1, 1, 0.f, NULL,
Image::OSG_UINT8_IMAGEDATA,
main_mem_image);
texObj->setImage(texImg);
texBuf->setTexture(texObj);
_fbo->setColorAttachment(texBuf, 0);
} else {
RenderBufferUnrecPtr renBuf = RenderBuffer::create();
_fbo->setColorAttachment(renBuf, 0);
}
_fbo->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT);
if (depth && !stencil) {
if (depth_stencil_texture) {
ImageUnrecPtr texImg = Image::create();
TextureObjChunkUnrecPtr texObj = TextureObjChunk::create();
TextureBufferUnrecPtr texBuf = TextureBuffer::create();
texImg->set(Image::OSG_L_PF,
width, height, 1, 1, 1, 0.f, NULL,
Image::OSG_UINT8_IMAGEDATA,
main_mem_image);
texObj->setImage(texImg);
texObj->setInternalFormat(GL_DEPTH_COMPONENT);
texObj->setExternalFormat(GL_DEPTH_COMPONENT);
texBuf->setTexture(texObj);
_fbo->setDepthAttachment(texBuf);
} else {
RenderBufferUnrecPtr renBuf = OSG::RenderBuffer::create();
renBuf->setInternalFormat(GL_DEPTH_COMPONENT24);
_fbo->setDepthAttachment(renBuf);
}
} else
if (depth && stencil) {
if (depth_stencil_texture) {
ImageUnrecPtr texImg = Image::create();
TextureObjChunkUnrecPtr texObj = TextureObjChunk::create();
TextureBufferUnrecPtr texBuf = TextureBuffer::create();
texImg->set(GL_DEPTH_STENCIL_EXT,
width, height, 1, 1, 1, 0.f, NULL,
GL_UNSIGNED_INT_24_8_EXT,
main_mem_image);
texObj->setImage(texImg);
texObj->setInternalFormat(GL_DEPTH24_STENCIL8_EXT);
texObj->setExternalFormat(GL_DEPTH_STENCIL_EXT);
texBuf->setTexture(texObj);
_fbo->setDepthAttachment(texBuf);
_fbo->setStencilAttachment(texBuf);
} else {
RenderBufferUnrecPtr renBuf = OSG::RenderBuffer::create();
renBuf->setInternalFormat(GL_DEPTH24_STENCIL8);
_fbo->setDepthAttachment(renBuf);
_fbo->setStencilAttachment(renBuf);
}
}
_fbo->setWidth (width );
_fbo->setHeight(height);
}
Carsten, could you please look if I have combined the pixel formats and data
types correctly. I have included glew.h manually and tried to find a way
through the world of pixel formats and data types.
What data type should be used typically for a depth buffer
GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT24 or GL_DEPTH_COMPONENT_ARB?
My intention is to build up a little machinery which provides me a FBO for
the most common cases, so that I do not have to puzzel it out each time I
have use of a FBO. The code above should be the starting point for this
endeavour.
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