From Art Trevs, moved multile render targets support from RenderStage into FrameBufferObject.

From Robert Osfield, refactored the FrameBufferObejcts::_drawBuffers set up so that its done
within the setAttachment  method to avoid potential threading/execution order issues.
This commit is contained in:
Robert Osfield
2008-04-15 19:36:40 +00:00
parent e1c6a6ea43
commit 9724303f38
5 changed files with 73 additions and 38 deletions

View File

@@ -556,7 +556,8 @@ FrameBufferObject::FrameBufferObject()
FrameBufferObject::FrameBufferObject(const FrameBufferObject &copy, const CopyOp &copyop)
: StateAttribute(copy, copyop),
_attachments(copy._attachments)
_attachments(copy._attachments),
_drawBuffers(copy._drawBuffers)
{
}
@@ -568,6 +569,26 @@ FrameBufferObject::~FrameBufferObject()
}
}
void FrameBufferObject::setAttachment(GLenum attachment_point, const FrameBufferAttachment &attachment)
{
_attachments[attachment_point] = attachment;
_drawBuffers.clear();
// create textures and mipmaps before we bind the frame buffer object
for (AttachmentMap::const_iterator i=_attachments.begin(); i!=_attachments.end(); ++i)
{
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);
}
dirtyAll();
}
void FrameBufferObject::apply(State &state) const
{
unsigned int contextID = state.getContextID();
@@ -615,7 +636,6 @@ void FrameBufferObject::apply(State &state) const
static OpenThreads::Mutex s_mutex;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex);
// create textures and mipmaps before we bind the frame buffer object
for (AttachmentMap::const_iterator i=_attachments.begin(); i!=_attachments.end(); ++i)
{
@@ -628,6 +648,16 @@ void FrameBufferObject::apply(State &state) const
ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
// enable drawing buffers to render the result to fbo
if (_drawBuffers.size() > 0)
{
GL2Extensions *gl2e = GL2Extensions::Get(state.getContextID(), true );
if (gl2e)
{
gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0]));
}
}
if (dirtyAttachmentList)
{
for (AttachmentMap::const_iterator i=_attachments.begin(); i!=_attachments.end(); ++i)