Commit af8f1470 authored by Christopher Tenter's avatar Christopher Tenter
Browse files

add support for #include in ACG shader load function

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@18397 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d2c16b73
......@@ -43,6 +43,7 @@
#include <QApplication>
#include <QDir>
#include <QString>
#include <QFileInfo>
#include <iostream>
#include <cassert>
......@@ -574,6 +575,38 @@ namespace GLSL {
while (!iShader.eof()) {
std::string strLine;
std::getline(iShader, strLine);
// check for includes
QString qstrLine = strLine.c_str();
if (qstrLine.contains("#include")) {
// try to load included file
QString strIncludeFile = qstrLine.remove("#include ").remove('\"').remove('<').remove('>').trimmed();
QFileInfo loadedShaderFile(path_file);
QString includePath = loadedShaderFile.absolutePath();
if (strIncludeFile.isEmpty())
std::cout << "wrong include syntax: " << strLine.c_str() << std::endl;
else {
QString fullPathToIncludeFile = includePath + QDir::separator() + strIncludeFile;
std::ifstream iInclude(fullPathToIncludeFile.toLatin1());
if (!iInclude) {
std::cout << "ERROR: Could not open file " << fullPathToIncludeFile.toStdString() << std::endl;
} else {
// append included file
while (!iInclude.eof()) {
std::getline(iInclude, strLine);
strLine += "\n";
shaderSource.push_back(strLine);
}
}
}
strLine = "";
}
strLine += "\n";
shaderSource.push_back(strLine);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment