Changed the FrameBufferObject::setAttachment() methods so it now use osg::Camera::BufferComponent
to enable it to distinguish between MRT and non MRT paths
This commit is contained in:
@@ -571,8 +571,43 @@ FrameBufferObject::~FrameBufferObject()
|
||||
|
||||
void FrameBufferObject::setAttachment(GLenum attachment_point, const FrameBufferAttachment &attachment)
|
||||
{
|
||||
setAttachment(convertGLenumToBufferComponent(attachment_point),attachment);
|
||||
}
|
||||
|
||||
void FrameBufferObject::setAttachment(BufferComponent attachment_point, const FrameBufferAttachment &attachment)
|
||||
{
|
||||
GLenum gl_attachment = convertBufferComponentToGLenum(attachment_point);
|
||||
_attachments[attachment_point] = attachment;
|
||||
|
||||
updateDrawBuffers();
|
||||
dirtyAll();
|
||||
}
|
||||
|
||||
|
||||
GLenum FrameBufferObject::convertBufferComponentToGLenum(BufferComponent attachment_point) const
|
||||
{
|
||||
switch(attachment_point)
|
||||
{
|
||||
case(Camera::DEPTH_BUFFER): return GL_DEPTH_ATTACHMENT_EXT;
|
||||
case(Camera::STENCIL_BUFFER): return GL_STENCIL_ATTACHMENT_EXT;
|
||||
case(Camera::COLOR_BUFFER): return GL_COLOR_ATTACHMENT0_EXT;
|
||||
default: return GLenum(GL_COLOR_ATTACHMENT0_EXT + (attachment_point-Camera::COLOR_BUFFER0));
|
||||
}
|
||||
}
|
||||
|
||||
FrameBufferObject::BufferComponent FrameBufferObject::convertGLenumToBufferComponent(GLenum attachment_point) const
|
||||
{
|
||||
switch(attachment_point)
|
||||
{
|
||||
case(GL_DEPTH_ATTACHMENT_EXT): return Camera::DEPTH_BUFFER;
|
||||
case(GL_STENCIL_ATTACHMENT_EXT): return Camera::STENCIL_BUFFER;
|
||||
case(GL_COLOR_ATTACHMENT0_EXT): return Camera::COLOR_BUFFER;
|
||||
default: return BufferComponent(Camera::COLOR_BUFFER0+(attachment_point-GL_COLOR_ATTACHMENT0_EXT));
|
||||
}
|
||||
}
|
||||
|
||||
void FrameBufferObject::updateDrawBuffers()
|
||||
{
|
||||
_drawBuffers.clear();
|
||||
|
||||
// create textures and mipmaps before we bind the frame buffer object
|
||||
@@ -581,12 +616,9 @@ void FrameBufferObject::setAttachment(GLenum attachment_point, const FrameBuffer
|
||||
const FrameBufferAttachment &fa = i->second;
|
||||
|
||||
// setup draw buffers based on the attachment definition
|
||||
if (i->first >= GL_COLOR_ATTACHMENT0_EXT && i->first <= GL_COLOR_ATTACHMENT15_EXT)
|
||||
_drawBuffers.push_back(i->first);
|
||||
if (i->first >= Camera::COLOR_BUFFER0 && i->first <= Camera::COLOR_BUFFER15)
|
||||
_drawBuffers.push_back(convertBufferComponentToGLenum(i->first));
|
||||
}
|
||||
|
||||
|
||||
dirtyAll();
|
||||
}
|
||||
|
||||
void FrameBufferObject::apply(State &state) const
|
||||
@@ -663,7 +695,7 @@ void FrameBufferObject::apply(State &state) const
|
||||
for (AttachmentMap::const_iterator i=_attachments.begin(); i!=_attachments.end(); ++i)
|
||||
{
|
||||
const FrameBufferAttachment &fa = i->second;
|
||||
fa.attach(state, i->first, ext);
|
||||
fa.attach(state, convertBufferComponentToGLenum(i->first), ext);
|
||||
}
|
||||
dirtyAttachmentList = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user