ShaderProgramControlAutoFiles.cc 1.5 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
#include <ACGL/OpenGL/Controller/ShaderProgramControlAutoFiles.hh>
#include <ACGL/OpenGL/Controller/ShaderControlFile.hh>
Robert Menzel's avatar
Robert Menzel committed
8
#include <ACGL/Resource/FileManager.hh>
Robert Menzel's avatar
Robert Menzel committed
9
#include <ACGL/OpenGL/Managers.hh>
Robert Menzel's avatar
Robert Menzel committed
10
11
12
#include <ACGL/Base/Settings.hh>

using namespace ACGL::Base;
Robert Menzel's avatar
Robert Menzel committed
13
14
using namespace ACGL::OpenGL;
//using namespace ACGL::Resource;
Robert Menzel's avatar
Robert Menzel committed
15
16
17
18

SharedShaderProgram ShaderProgramControlAutoFiles::create(void)
{
    SharedShaderProgram shaderProgram(new ShaderProgram());
19
    if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".vsh").type(GL_VERTEX_SHADER)))
Robert Menzel's avatar
Robert Menzel committed
20
        shaderProgram->attachShader(shader);
21
    if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".fsh").type(GL_FRAGMENT_SHADER)))
Robert Menzel's avatar
Robert Menzel committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        shaderProgram->attachShader(shader);
    if(shaderProgram->link())
        return shaderProgram;
    return SharedShaderProgram();
}

bool ShaderProgramControlAutoFiles::update(SharedShaderProgram& shaderProgram)
{
    bool update = false;
    update |= ShaderFileManager::the()->update(mFilename + ".vsh");
    update |= ShaderFileManager::the()->update(mFilename + ".fsh");
    if(update)
        return shaderProgram->link();
    return false;
}