Commit 59980a01 authored by Janis Born's avatar Janis Born

FrameBufferObject:

    * remove unused mBufferMappings
    * warn when mapping multiple locations to same attachment
    * cap size for bufferMappings at GL_MAX_DRAW_BUFFERS
    * bind FBO before validate()
parent aa066185
......@@ -211,7 +211,6 @@ protected:
GLuint mObjectName;
AttachmentVec mColorAttachments;
Attachment mDepthAttachment; // depth and stencil are combined
GLuint mBufferMappings[8]; // maps from mColorAttachment.loction (shader outs) to FBO locations (order of mColorAttachments)
};
ACGL_SHARED_TYPEDEF(FrameBufferObject)
......
......@@ -21,6 +21,7 @@ int_t FrameBufferObject::getColorAttachmentIndexByName(const std::string& _name)
bool FrameBufferObject::isFrameBufferObjectComplete() const
{
bind();
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
......@@ -121,20 +122,27 @@ bool FrameBufferObject::attachColorAttachment( const Attachment &_attachment )
void FrameBufferObject::remapAttachments()
{
// max color attachments: 8, TODO
const int maxColorBuffers = 8;
GLenum bufferMappings[maxColorBuffers];
GLint maxColorBuffers;
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxColorBuffers);
GLenum* bufferMappings = new GLenum[maxColorBuffers];
unsigned int attachments = std::min( maxColorBuffers, (int) mColorAttachments.size() );
for (unsigned int i = 0; i < maxColorBuffers; ++i) {
bufferMappings[i] = GL_NONE;
}
for (unsigned int i = 0; i < attachments; ++i) {
if (bufferMappings[ mColorAttachments[i].location ] != GL_NONE) {
Utils::warning() << "FBO: Attachment mapping collision: Location " << mColorAttachments[i].location;
Utils::warning() << " maps to both attachments " << mColorAttachments[i].name;
Utils::warning() << " and " << mColorAttachments[bufferMappings[mColorAttachments[i].location] - GL_COLOR_ATTACHMENT0].name << std::endl;
}
bufferMappings[ mColorAttachments[i].location ] = GL_COLOR_ATTACHMENT0 + i;
}
// debug:
Utils::message() << "remapAttachments: " << std::endl;
/*
Utils::debug() << "remapAttachments: " << std::endl;
for (unsigned int i = 0; i < maxColorBuffers; ++i) {
if (bufferMappings[i] == GL_NONE) {
Utils::debug() << "bufferMappings["<<i<<"] GL_NONE" << std::endl;
......@@ -142,11 +150,13 @@ void FrameBufferObject::remapAttachments()
Utils::debug() << "bufferMappings["<<i<<"] "<< bufferMappings[i]-GL_COLOR_ATTACHMENT0 << std::endl;
}
}
*/
// end debug
bind(); // glDrawBuffers will get part of the FBO state!
glDrawBuffers( maxColorBuffers, bufferMappings );
delete[] bufferMappings;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment