ninja commit on shader source class
This commit is contained in:
parent
4aaf417cde
commit
5305fdeac2
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
|
||||
private:
|
||||
char* sources[NB_TYPES];
|
||||
|
||||
void preprocess(std::string &source, int nbDefines, const char** defines);
|
||||
};
|
||||
|
||||
#endif // SHADERSOURCE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user