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) if(sources[VERTEX] == NULL || sources[FRAGMENT] == NULL)
return NULL; return NULL;
std::string plop(sources[VERTEX]); std::string compiledSources[NB_TYPES];
plop.find("#if") for(int i=0; i<NB_TYPES; ++i)
{ {
if(sources[i] == NULL)
continue;
compiledSources[i] = std::string(sources[i]);
preprocess(compiledSources[i], nbDefines, defines);
} }
if(sources[GEOMETRY] != NULL)
// read lines return new Shader(compiledSources[VERTEX], compiledSources[GEOMETRY], compiledSources[FRAGMENT]);
else if(sources[GEOMETRY] != NULL)
return new Shader(sources[VERTEX], sources[GEOMETRY], sources[FRAGMENT]);
else 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: private:
char* sources[NB_TYPES]; char* sources[NB_TYPES];
void preprocess(std::string &source, int nbDefines, const char** defines);
}; };
#endif // SHADERSOURCE_H #endif // SHADERSOURCE_H