Commit 0191bfdf authored by Andreas Neu's avatar Andreas Neu
Browse files

* Added the possibility to modifiy the texture targets for a framebufferobject

parent 9f51e032
......@@ -32,6 +32,7 @@
#include <ACGL/OpenGL/Objects/Texture.hh>
#include <vector>
#include <map>
#include <tr1/memory>
namespace ACGL{
......@@ -150,9 +151,11 @@ public:
Utils::error() << "Attaching of texture to the FBO failed" << std::endl;
return false;
}
mDrawBuffers++;
Attachment attachment = {_name, SharedTexture(), _renderBuffer};
mColorAttachments.push_back(attachment);
mColorAttachmentIndices[_name] = mDrawBuffers;
mDrawBuffers++;
return true;
}
......@@ -163,9 +166,23 @@ public:
Utils::error() << "Attaching of texture to the FBO failed" << std::endl;
return false;
}
mDrawBuffers++;
Attachment attachment = {_name, _texture, SharedRenderBuffer()};
mColorAttachments.push_back(attachment);
mColorAttachmentIndices[_name] = mDrawBuffers;
mDrawBuffers++;
return true;
}
inline bool setColorRenderBuffer(const std::string _name, const ConstSharedRenderBuffer& _renderBuffer)
{
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + mColorAttachmentIndices[_name], GL_RENDERBUFFER, _renderBuffer->getObjectName() );
return true;
}
inline bool setColorTexture(const std::string _name, const ConstSharedTexture& _texture)
{
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + mColorAttachmentIndices[_name], _texture->getTarget(), _texture->getObjectName(), 0 );
return true;
}
......@@ -208,6 +225,8 @@ protected:
GLuint mObjectName;
GLsizei mDrawBuffers;
AttachmentVec mColorAttachments;
//stores the attachment index (GL_COLOR_ATTACHMENT0 + i) of each color attachment by its name.
std::map<std::string, int> mColorAttachmentIndices;
Attachment mDepthAttachment; // depth and stencil are combined
};
......
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