From Jaromir Vitek, "patch contains extension to fbo and camera. Camera can attach new render buffer for depth and stencil logical buffer in packed form."

This commit is contained in:
Robert Osfield
2008-11-09 11:55:11 +00:00
parent d75cd032b9
commit 2090fb1450
3 changed files with 38 additions and 2 deletions

View File

@@ -310,6 +310,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
{
DEPTH_BUFFER,
STENCIL_BUFFER,
PACKED_DEPTH_STENCIL_BUFFER,
COLOR_BUFFER,
COLOR_BUFFER0,
COLOR_BUFFER1 = COLOR_BUFFER0+1,

View File

@@ -114,6 +114,14 @@
#define GL_DEPTH_COMPONENT32 0x81A7
#endif
#ifndef GL_EXT_packed_depth_stencil
#define GL_EXT_packed_depth_stencil 1
#define GL_DEPTH_STENCIL_EXT 0x84F9
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
#endif
namespace osg
{
@@ -165,11 +173,13 @@ namespace osg
bool isSupported() const { return _supported; }
bool isMultisampleSupported() const { return glRenderbufferStorageMultisampleEXT != 0; }
bool isMultisampleCoverageSupported() const { return glRenderbufferStorageMultisampleCoverageNV != 0; }
bool isPackedDepthStencilSupported() const { return _packed_depth_stencil_supported; }
protected:
FBOExtensions(unsigned int contextID);
bool _supported;
bool _packed_depth_stencil_supported;
};
/**************************************************************************

View File

@@ -58,7 +58,8 @@ FBOExtensions::FBOExtensions(unsigned int contextID)
glFramebufferRenderbufferEXT(0),
glGenerateMipmapEXT(0),
glBlitFramebufferEXT(0),
_supported(false)
_supported(false),
_packed_depth_stencil_supported(false)
{
if (!isGLExtensionSupported(contextID, "GL_EXT_framebuffer_object"))
return;
@@ -107,6 +108,11 @@ FBOExtensions::FBOExtensions(unsigned int contextID)
{
LOAD_FBO_EXT(glRenderbufferStorageMultisampleCoverageNV);
}
if (isGLExtensionSupported(contextID, "GL_EXT_packed_depth_stencil"))
{
_packed_depth_stencil_supported = true;
}
}
@@ -811,7 +817,26 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
for (AttachmentMap::const_iterator i=_attachments.begin(); i!=_attachments.end(); ++i)
{
const FrameBufferAttachment &fa = i->second;
fa.attach(state, target, convertBufferComponentToGLenum(i->first), ext);
switch(i->first)
{
case(Camera::PACKED_DEPTH_STENCIL_BUFFER):
if (ext->isPackedDepthStencilSupported())
{
fa.attach(state, target, GL_DEPTH_ATTACHMENT_EXT, ext);
fa.attach(state, target, GL_STENCIL_ATTACHMENT_EXT, ext);
}
else
{
notify(WARN) <<
"Warning: FrameBufferObject: could not attach PACKED_DEPTH_STENCIL_BUFFER, "
"EXT_packed_depth_stencil is not supported !" << std::endl;
}
break;
default:
fa.attach(state, target, convertBufferComponentToGLenum(i->first), ext);
break;
}
}
dirtyAttachmentList = 0;
}