Commit 8028d1f8 authored by Andreas Neu's avatar Andreas Neu
Browse files

-By assigning the shader to the FrameBufferObject Controller you can now...

-By assigning the shader to the FrameBufferObject Controller you can now assign the FragmentData Targets in a different order.
parent c7108e6b
......@@ -14,6 +14,9 @@
#include <ACGL/OpenGL/Objects/Texture.hh>
#include <ACGL/OpenGL/Objects/RenderBuffer.hh>
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
#include <vector>
namespace ACGL{
namespace OpenGL{
......@@ -26,7 +29,8 @@ class FrameBufferObjectControl : public Resource::BasicCreateController<FrameBuf
public:
FrameBufferObjectControl(void)
: mColorAttachments(),
mDepthAttachment()
mDepthAttachment(),
mpShaderProgram()
{
mDepthAttachment.name = "";
mDepthAttachment.texture = ConstSharedTexture();
......@@ -40,6 +44,7 @@ public:
public:
inline FrameBufferObjectControl& depthTexture (const ConstSharedTexture& _pDepthTexture) { mDepthAttachment.texture = _pDepthTexture; return *this; }
inline FrameBufferObjectControl& depthRenderBuffer (const ConstSharedRenderBuffer& _pDepthRenderBuffer) { mDepthAttachment.renderBuffer = _pDepthRenderBuffer; return *this; }
inline FrameBufferObjectControl& shaderProgram (const ConstSharedShaderProgram& _shaderProgram) { mpShaderProgram = _shaderProgram; return *this; }
inline FrameBufferObjectControl& colorTexture(const std::string& _name, const ConstSharedTexture& _texture)
{
......@@ -66,6 +71,7 @@ public:
protected:
FrameBufferObject::AttachmentVec mColorAttachments;
FrameBufferObject::Attachment mDepthAttachment;
ConstSharedShaderProgram mpShaderProgram;
};
} // OpenGL
......
......@@ -7,17 +7,42 @@
using namespace ACGL::OpenGL;
// inline GLint getFragmentDataLocation (const std::string& _nameInShader) const { return glGetFragDataLocation(mContext, _nameInShader.c_str()); }
SharedFrameBufferObject FrameBufferObjectControl::create(void)
{
SharedFrameBufferObject frameBuffer(new FrameBufferObject());
frameBuffer->bind();
for(FrameBufferObject::AttachmentVec::size_type i = 0; i < mColorAttachments.size(); ++i)
if(mpShaderProgram)
{
std::vector<int_t> assignmentOrder(mColorAttachments.size());
for(FrameBufferObject::AttachmentVec::size_type i = 0; i < mColorAttachments.size(); ++i)
{
GLint location = mpShaderProgram->getFragmentDataLocation(mColorAttachments[i].name);
assignmentOrder[location] = i;
}
for(std::vector<int_t>::size_type j = 0; j < assignmentOrder.size(); ++j)
{
if(mColorAttachments[assignmentOrder[j]].texture)
frameBuffer->attachColorTexture(mColorAttachments[assignmentOrder[j]].name, mColorAttachments[assignmentOrder[j]].texture);
else if(mColorAttachments[assignmentOrder[j]].renderBuffer)
frameBuffer->attachColorRenderBuffer(mColorAttachments[assignmentOrder[j]].name, mColorAttachments[assignmentOrder[j]].renderBuffer);
}
}
else
{
if(mColorAttachments[i].texture)
frameBuffer->attachColorTexture(mColorAttachments[i].name, mColorAttachments[i].texture);
else if(mColorAttachments[i].renderBuffer)
frameBuffer->attachColorRenderBuffer(mColorAttachments[i].name, mColorAttachments[i].renderBuffer);
for(FrameBufferObject::AttachmentVec::size_type i = 0; i < mColorAttachments.size(); ++i)
{
if(mColorAttachments[i].texture)
frameBuffer->attachColorTexture(mColorAttachments[i].name, mColorAttachments[i].texture);
else if(mColorAttachments[i].renderBuffer)
frameBuffer->attachColorRenderBuffer(mColorAttachments[i].name, mColorAttachments[i].renderBuffer);
}
}
if(mDepthAttachment.texture)
......
Supports Markdown
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