FrameBufferControl.hh 3.69 KB
Newer Older
Robert Menzel's avatar
Robert Menzel committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University         //
// All rights reserved.                                                       //
////////////////////////////////////////////////////////////////////////////////

Robert Menzel's avatar
Robert Menzel committed
6 7 8
#ifndef ACGL_RESOURCE_FRAMEBUFFERCONTROL_HH
#define ACGL_RESOURCE_FRAMEBUFFERCONTROL_HH

Robert Menzel's avatar
Robert Menzel committed
9 10
#include <ACGL/ACGL.hh>

Robert Menzel's avatar
Robert Menzel committed
11
#include <ACGL/Resource/BasicController.hh>
Robert Menzel's avatar
Robert Menzel committed
12 13 14 15 16
#include <ACGL/OpenGL/Objects/FrameBuffer.hh>
#include <ACGL/OpenGL/GL.hh>

#include <ACGL/OpenGL/Objects/Texture.hh>
#include <ACGL/OpenGL/Objects/RenderBuffer.hh>
Robert Menzel's avatar
Robert Menzel committed
17 18

namespace ACGL{
Robert Menzel's avatar
Robert Menzel committed
19
namespace OpenGL{
Robert Menzel's avatar
Robert Menzel committed
20

Robert Menzel's avatar
Robert Menzel committed
21
class FrameBufferControl : public Resource::BasicController<FrameBuffer>
Robert Menzel's avatar
Robert Menzel committed
22 23 24 25 26 27 28 29 30 31 32
{
    // ========================================================================================================= \/
    // ============================================================================================ CONSTRUCTORS \/
    // ========================================================================================================= \/
public:
    FrameBufferControl(void) :
        mWidth(0),
        mHeight(0),
        mColorAttachments(),
        mDepthAttachment()
    {
Robert Menzel's avatar
Robert Menzel committed
33 34
        mDepthAttachment.name         = "";
        mDepthAttachment.texture      = SharedTexture();
Robert Menzel's avatar
Robert Menzel committed
35 36 37 38 39 40 41 42
        mDepthAttachment.renderBuffer = SharedRenderBuffer();
    }
    virtual ~FrameBufferControl() {}

    // ==================================================================================================== \/
    // ============================================================================================ METHODS \/
    // ==================================================================================================== \/
public:
Robert Menzel's avatar
Robert Menzel committed
43
    inline FrameBufferControl& size              (GLsizei _width, GLsizei _height)                        { mWidth = _width; mHeight = _height;                  return *this; }
Robert Menzel's avatar
Robert Menzel committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    inline FrameBufferControl& depthTexture      (const SharedTexture& _pDepthTexture)           { mDepthAttachment.texture = _pDepthTexture;           return *this; }
    inline FrameBufferControl& depthRenderBuffer (const SharedRenderBuffer& _pDepthRenderBuffer) { mDepthAttachment.renderBuffer = _pDepthRenderBuffer; return *this; }

    inline FrameBufferControl& colorTexture(const SharedTexture& _texture)
    {
        FrameBuffer::Attachment attachment = {"", _texture, SharedRenderBuffer()};
        mColorAttachments.push_back(attachment);
        return *this;
    }
    inline FrameBufferControl& colorRenderBuffer(const SharedRenderBuffer& _renderBuffer)
    {
        FrameBuffer::Attachment attachment = {"", SharedTexture(), _renderBuffer};
        mColorAttachments.push_back(attachment);
        return *this;
    }

    // ===================================================================================================== \/
    // ============================================================================================ OVERRIDE \/
    // ===================================================================================================== \/
public:
    virtual SharedFrameBuffer create (void);

    // =================================================================================================== \/
    // ============================================================================================ FIELDS \/
    // =================================================================================================== \/
protected:
    GLsizei                    mWidth;
    GLsizei                    mHeight;
    FrameBuffer::AttachmentVec mColorAttachments;
    FrameBuffer::Attachment    mDepthAttachment;
};

Robert Menzel's avatar
Robert Menzel committed
76
} // OpenGL
Robert Menzel's avatar
Robert Menzel committed
77 78 79
} // ACGL

#endif // ACGL_RESOURCE_TEXTURE_HH