FrameBufferObjectControl.cc 1.56 KB
Newer Older
1
2
3
4
5
/***********************************************************************
 * Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
 * All rights reserved.                                                *
 * Distributed under the terms of the MIT License (see LICENSE.TXT).   *
 **********************************************************************/
Robert Menzel's avatar
Robert Menzel committed
6

7
#include <ACGL/OpenGL/Controller/FrameBufferObjectControl.hh>
Robert Menzel's avatar
Robert Menzel committed
8

Robert Menzel's avatar
Robert Menzel committed
9
using namespace ACGL::OpenGL;
Robert Menzel's avatar
Robert Menzel committed
10

11
SharedFrameBufferObject FrameBufferObjectControl::create(void)
Robert Menzel's avatar
Robert Menzel committed
12
{
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    SharedFrameBufferObject fbo = SharedFrameBufferObject(new FrameBufferObject());

    // attach all defined color Textures and RenderBuffers
    for(FrameBufferObject::AttachmentVec::iterator it = mColorAttachments.begin();
        it != mColorAttachments.end();
        ++it)
    {
        if(it->texture)
            fbo->attachColorTexture(it->name, it->texture);
        else if(it->renderBuffer)
            fbo->attachColorRenderBuffer(it->name, it->renderBuffer);
    }

    // attach the depth attachment
    if(mDepthAttachment.texture)
        fbo->setDepthTexture(mDepthAttachment.texture);
    else if(mDepthAttachment.renderBuffer)
        fbo->setDepthRenderBuffer(mDepthAttachment.renderBuffer);

    // update the LocationMappings mapping, if present
    if(mFragDataLocations)
    {
35
        fbo->setAttachmentLocations(mFragDataLocations);
36
37
        SharedLocationMappings fboMappings = fbo->getAttachmentLocations();
        mFragDataLocations->addLocations(fboMappings);
38
        fbo->setAttachmentLocations(mFragDataLocations);
39
40
41
    }

    return fbo;
Robert Menzel's avatar
Robert Menzel committed
42
}