Commit ba25d665 authored by Janis Born's avatar Janis Born
Browse files

ShaderProgramControlAutoFiles only tries to load shader files other than .vsh...

ShaderProgramControlAutoFiles only tries to load shader files other than .vsh and .fsh if they actually exist; also try to load tessellation control (.tcsh) / evaluation (.tesh) shaders
parent 5cc2583a
......@@ -61,6 +61,11 @@ namespace FileHelpers
* Will return the modification time of the file.
*/
FileModificationTime getFileModificationTime( const std::string &fileName ) ;
/*
* Checks whether a file with the given filename exists and is readable.
*/
bool fileExists( const std::string &fileName );
}
} // Base
......
......@@ -103,6 +103,12 @@ namespace FileHelpers
stat(fileName.c_str(), &fileStats);
return fileStats.st_mtime;
}
bool fileExists(const std::string &fileName)
{
std::ifstream file(fileName);
return file.good();
}
}
} // Base
......
......@@ -22,6 +22,10 @@ SharedShader ShaderControlFile::create(void)
if(extension == "vsh")
mType = GL_VERTEX_SHADER;
else if(extension == "tcsh")
mType = GL_TESS_CONTROL_SHADER;
else if(extension == "tesh")
mType = GL_TESS_EVALUATION_SHADER;
else if(extension == "gsh")
mType = GL_GEOMETRY_SHADER;
else if(extension == "fsh")
......
......@@ -8,6 +8,7 @@
#include <ACGL/Resource/FileManager.hh>
#include <ACGL/OpenGL/Managers.hh>
#include <ACGL/Base/Settings.hh>
#include <ACGL/Base/FileHelpers.hh>
using namespace ACGL::Base;
using namespace ACGL::OpenGL;
......@@ -18,8 +19,19 @@ SharedShaderProgram ShaderProgramControlAutoFiles::create(void)
SharedShaderProgram shaderProgram(new ShaderProgram());
if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".vsh").type(GL_VERTEX_SHADER)))
shaderProgram->attachShader(shader);
if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".gsh").type(GL_GEOMETRY_SHADER)))
shaderProgram->attachShader(shader);
if(FileHelpers::fileExists(Base::Settings::the()->getFullShaderPath() + mFilename + ".tcsh"))
if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".tcsh").type(GL_TESS_CONTROL_SHADER)))
shaderProgram->attachShader(shader);
if(FileHelpers::fileExists(Base::Settings::the()->getFullShaderPath() + mFilename + ".tesh"))
if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".tesh").type(GL_TESS_EVALUATION_SHADER)))
shaderProgram->attachShader(shader);
if(FileHelpers::fileExists(Base::Settings::the()->getFullShaderPath() + mFilename + ".gsh"))
if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".gsh").type(GL_GEOMETRY_SHADER)))
shaderProgram->attachShader(shader);
if(ConstSharedShader shader = ShaderFileManager::the()->get(ShaderControlFile(mFilename + ".fsh").type(GL_FRAGMENT_SHADER)))
shaderProgram->attachShader(shader);
......@@ -30,6 +42,7 @@ SharedShaderProgram ShaderProgramControlAutoFiles::create(void)
if(shaderProgram->link())
return shaderProgram;
return SharedShaderProgram();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment