ninja commit on shader source class

This commit is contained in:
Anselme 2015-11-23 18:27:59 +01:00
parent 4aaf417cde
commit 5305fdeac2
2 changed files with 22 additions and 9 deletions

View File

@ -13,17 +13,28 @@ Shader* ShaderSource::compile(int nbDefines = 0, const char** defines = NULL)
{
if(sources[VERTEX] == NULL || sources[FRAGMENT] == NULL)
return NULL;
std::string plop(sources[VERTEX]);
plop.find("#if")
std::string compiledSources[NB_TYPES];
for(int i=0; i<NB_TYPES; ++i)
{
if(sources[i] == NULL)
continue;
compiledSources[i] = std::string(sources[i]);
preprocess(compiledSources[i], nbDefines, defines);
}
// read lines
else if(sources[GEOMETRY] != NULL)
return new Shader(sources[VERTEX], sources[GEOMETRY], sources[FRAGMENT]);
if(sources[GEOMETRY] != NULL)
return new Shader(compiledSources[VERTEX], compiledSources[GEOMETRY], compiledSources[FRAGMENT]);
else
return new Shader(sources[VERTEX], sources[FRAGMENT]);
return new Shader(compiledSources[VERTEX], compiledSources[FRAGMENT]);
}
void ShaderSource::preprocess(std::string &source, int nbDefines, const char** defines)
{
std::istringstream f("line1\nline2\nline3");
std::string line;
while (std::getline(f, line)) {
if(line.at(0) == '#')
{
// TODO
}
}
}

View File

@ -24,6 +24,8 @@ public:
private:
char* sources[NB_TYPES];
void preprocess(std::string &source, int nbDefines, const char** defines);
};
#endif // SHADERSOURCE_H