SparrowRenderer/shadersource.cpp
2015-11-23 18:27:59 +01:00

41 lines
1.1 KiB
C++

#include "shadersource.h"
#include <string>
#include "shader.h"
ShaderSource::ShaderSource();
void ShaderSource::addSource(const char *source, SourceType type)
{
}
Shader* ShaderSource::compile(int nbDefines = 0, const char** defines = NULL)
{
if(sources[VERTEX] == NULL || sources[FRAGMENT] == NULL)
return NULL;
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);
}
if(sources[GEOMETRY] != NULL)
return new Shader(compiledSources[VERTEX], compiledSources[GEOMETRY], compiledSources[FRAGMENT]);
else
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
}
}
}