25 #include <OpenGLFramework/Utils/FramebufferSetup.hh>
26 #include <OpenGLFramework/Base/glfFBOAttachmentReleaseException.hh>
31 FramebufferSetup::FramebufferSetup() :
32 fbo_(NULL), clearColorBuffer_(false), clearDepthBuffer_(false), clearDepth_(
33 1.0f), depthAttachment_(NULL)
35 for (
unsigned int i = 0; i < 4; i++)
36 clearColor_[i] = 0.0f;
42 BIASASSERT(fbo != NULL);
50 if (AttachmentPoint >= static_cast<int> (colorAttachments_.size()))
52 colorAttachments_.resize(AttachmentPoint + 1, NULL);
54 colorAttachments_[AttachmentPoint] = texture;
61 colorAttachments_.clear();
69 colorAttachments_.clear();
70 colorAttachments_ = textures;
76 depthAttachment_ = texture;
82 if (AttachmentPoint >= static_cast<int> (colorAttachments_.size()))
88 return dynamic_cast<glfTexture2D*
> (colorAttachments_[AttachmentPoint]);
97 clearColor_[1] = green;
98 clearColor_[2] = blue;
99 clearColor_[3] = alpha;
100 clearColorBuffer_ =
true;
107 clearDepthBuffer_ =
true;
113 clearColorBuffer_ =
false;
119 clearDepthBuffer_ =
false;
125 BIASASSERT(fbo_ != NULL);
126 const unsigned int numRT =
128 vector<GLenum> renderBuffers;
129 renderBuffers.reserve(numRT);
130 for (
unsigned int i = 0; i < colorAttachments_.size(); i++)
132 if (colorAttachments_[i] != NULL)
134 fbo_->
AttachTexture(*(colorAttachments_[i]), GL_COLOR_ATTACHMENT0_EXT
136 renderBuffers.push_back(GL_COLOR_ATTACHMENT0_EXT + i);
152 for (
unsigned int i = colorAttachments_.size(); i < numRT; i++)
164 if (depthAttachment_ != NULL)
166 fbo_->
AttachTexture(*depthAttachment_, GL_DEPTH_ATTACHMENT_EXT);
184 if (clearColorBuffer_)
189 if (clearDepthBuffer_)
void AttachTexture(const glfTexture &texture, GLenum attachmentPoint, int attachedMipMapLevel=0, int zSlice=0, GLenum cubeMapSide=0)
Attaches a texture to an attachment point which can be.
void ClearColorAttachments()
static GLint MaxRenderTargets()
void SetDepthAttachment(BIAS::glfTexture *texture)
void SetDrawBuffers(const std::vector< GLenum > &drawbuffers)
void ReleaseAttachment(GLenum attachmentPoint)
Removes an attachment from the framebuffer object.
void SetColorAttachments(const std::vector< BIAS::glfTexture * > &textures)
replaces all previous color attachments and through given
Class is thrown when an release of some FBO attachment point is not possible.
void DisableColorClearance()
void CheckComplete() const
Checks whether the framebuffer object is supported in its current state.
void EnableColorClearance(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
void ClearDepthBuffer(float depth=1.0f)
Clears the depth buffer of the render target with the given value.
void LinkFBO(BIAS::glfFramebufferObject *fbo)
void DisableDepthClearance()
void SetColorAttachment(BIAS::glfTexture *texture, int AttachmentPoint=0)
void ClearColorBuffer(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
Clears the color buffer of the render target with the given color.
void EnableDepthClearance(float depth=1.0f)
glfTexture2D * GetColorAttachment2D(int AttachmentPoint)
Returns texture attached to AttachmentPoint if it is a glfTexture2D otherwise NULL.