FrameBufferControl.hh 3.78 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.                                                       //
////////////////////////////////////////////////////////////////////////////////

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

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

11
#include <ACGL/Resource/BasicCreateController.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

21
class FrameBufferControl : public Resource::BasicCreateController<FrameBuffer>
Robert Menzel's avatar
Robert Menzel committed
22
23
24
25
26
{
    // ========================================================================================================= \/
    // ============================================================================================ CONSTRUCTORS \/
    // ========================================================================================================= \/
public:
27
28
    FrameBufferControl(void)
    :   mWidth(0),
Robert Menzel's avatar
Robert Menzel committed
29
30
31
32
        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:
43
    inline FrameBufferControl& size              (GLsizei _width, GLsizei _height)               { mWidth = _width; mHeight = _height;                  return *this; }
Robert Menzel's avatar
Robert Menzel committed
44
45
46
    inline FrameBufferControl& depthTexture      (const SharedTexture& _pDepthTexture)           { mDepthAttachment.texture = _pDepthTexture;           return *this; }
    inline FrameBufferControl& depthRenderBuffer (const SharedRenderBuffer& _pDepthRenderBuffer) { mDepthAttachment.renderBuffer = _pDepthRenderBuffer; return *this; }

47
    inline FrameBufferControl& colorTexture(const std::string& _name, const SharedTexture& _texture)
Robert Menzel's avatar
Robert Menzel committed
48
    {
49
        FrameBuffer::Attachment attachment = {_name, _texture, SharedRenderBuffer()};
Robert Menzel's avatar
Robert Menzel committed
50
51
52
        mColorAttachments.push_back(attachment);
        return *this;
    }
53
    inline FrameBufferControl& colorRenderBuffer(const std::string& _name, const SharedRenderBuffer& _renderBuffer)
Robert Menzel's avatar
Robert Menzel committed
54
    {
55
        FrameBuffer::Attachment attachment = {_name, SharedTexture(), _renderBuffer};
Robert Menzel's avatar
Robert Menzel committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
        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
} // ACGL

79
#endif // ACGL_OPENGL_CONTROLLER_FRAMEBUFFERCONTROL_HH