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)
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user