Commit 5ee0ad7b authored by Robert Menzel's avatar Robert Menzel

changed behavior of replacing color attachments, avoids GL_NONE on attachment...

changed behavior of replacing color attachments, avoids GL_NONE on attachment 0 (would trigger a mac bug)
parent b8e28275
cmake @ 809ae57e
Subproject commit fbc7a6c6d438fd390368709eb7727f3a522bfe27
Subproject commit 809ae57efe0fb1b44c069aacfabd3f5f988cafdb
......@@ -122,13 +122,13 @@ public:
*/
inline bool attachColorRenderBuffer(const std::string &_name, const ConstSharedRenderBuffer& _renderBuffer)
{
Attachment a = {_name, SharedTexture(), _renderBuffer, (GLuint) mColorAttachments.size()};
Attachment a = {_name, SharedTexture(), _renderBuffer, 0xFFFFFFFF /*(GLuint) mColorAttachments.size()*/};
return attachColorAttachment( a );
}
inline bool attachColorTexture(const std::string &_name, const ConstSharedTexture& _texture)
{
Attachment a = {_name, _texture, SharedRenderBuffer(), (GLuint) mColorAttachments.size()};
Attachment a = {_name, _texture, SharedRenderBuffer(), 0xFFFFFFFF /*(GLuint) mColorAttachments.size()*/};
return attachColorAttachment( a );
}
......@@ -144,6 +144,9 @@ public:
return attachColorAttachment( a );
}
// if the location within the attachment is larger than the possible number of attachments,
// attachColorAttachment will try to find a non-colliding attachment point.
// this can be used to say "i don't care about the actual attachment number used"
bool attachColorAttachment( const Attachment &_attachment );
void remapAttachments();
......
......@@ -85,18 +85,33 @@ void FrameBufferObject::validate(void) const
bool FrameBufferObject::attachColorAttachment( const Attachment &_attachment )
{
int realLocation = -1;
GLint maxColorBuffers;
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxColorBuffers);
for (unsigned int i = 0; i < mColorAttachments.size(); ++i) {
if (mColorAttachments[i].name == _attachment.name) {
// replace this attachment
GLuint newLocation = _attachment.location;
if (newLocation > maxColorBuffers) {
// we have to find a place, but luckily we can use the old location of the same-named attachment:
newLocation = mColorAttachments[i].location;
}
mColorAttachments[i] = _attachment;
mColorAttachments[i].location = newLocation;
realLocation = i;
}
}
if (realLocation == -1) {
// it's a new attachment
GLuint newLocation = _attachment.location;
if (newLocation > maxColorBuffers) {
// we have to find a place:
newLocation = mColorAttachments.size();
}
realLocation = (int) mColorAttachments.size();
mColorAttachments.push_back(_attachment);
mColorAttachments[mColorAttachments.size()-1].location = newLocation;
}
// attach it to the OpenGL object:
......@@ -141,16 +156,18 @@ void FrameBufferObject::remapAttachments()
}
// debug:
/*
Utils::debug() << "remapAttachments: " << std::endl;
/*
if (bufferMappings[0] == GL_NONE) {
Utils::error() << "remapAttachments: " << std::endl;
for (unsigned int i = 0; i < maxColorBuffers; ++i) {
if (bufferMappings[i] == GL_NONE) {
Utils::debug() << "bufferMappings["<<i<<"] GL_NONE" << std::endl;
Utils::error() << "bufferMappings["<<i<<"] GL_NONE" << std::endl;
} else {
Utils::debug() << "bufferMappings["<<i<<"] "<< bufferMappings[i]-GL_COLOR_ATTACHMENT0 << std::endl;
Utils::error() << "bufferMappings["<<i<<"] "<< bufferMappings[i]-GL_COLOR_ATTACHMENT0 << std::endl;
}
}
*/
}*/
// end debug
bind(); // glDrawBuffers will get part of the FBO state!
......
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