mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Take into account previous #line directives when expanding @foreach shader macros
This commit is contained in:
parent
590531595b
commit
3d18ddc8e4
2 changed files with 16 additions and 4 deletions
|
@ -123,8 +123,22 @@ namespace Shader
|
||||||
std::string content = source.substr(contentStart, contentEnd - contentStart);
|
std::string content = source.substr(contentStart, contentEnd - contentStart);
|
||||||
|
|
||||||
size_t overallEnd = contentEnd + std::string("$endforeach").length();
|
size_t overallEnd = contentEnd + std::string("$endforeach").length();
|
||||||
// This will be wrong if there are other #line directives, so that needs fixing
|
|
||||||
int lineNumber = std::count(source.begin(), source.begin() + overallEnd, '\n') + 2;
|
size_t lineDirectivePosition = source.rfind("#line", overallEnd);
|
||||||
|
int lineNumber;
|
||||||
|
if (lineDirectivePosition != std::string::npos)
|
||||||
|
{
|
||||||
|
size_t lineNumberStart = lineDirectivePosition + std::string("#line ").length();
|
||||||
|
size_t lineNumberEnd = source.find_first_not_of("0123456789", lineNumberStart);
|
||||||
|
std::string lineNumberString = source.substr(lineNumberStart, lineNumberEnd - lineNumberStart);
|
||||||
|
lineNumber = std::stoi(lineNumberString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lineDirectivePosition = 0;
|
||||||
|
lineNumber = 2;
|
||||||
|
}
|
||||||
|
lineNumber += std::count(source.begin() + lineDirectivePosition, source.begin() + overallEnd, '\n');
|
||||||
|
|
||||||
std::string replacement = "";
|
std::string replacement = "";
|
||||||
for (std::vector<std::string>::const_iterator element = listElements.cbegin(); element != listElements.cend(); element++)
|
for (std::vector<std::string>::const_iterator element = listElements.cbegin(); element != listElements.cend(); element++)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
//DUMPME
|
|
||||||
|
|
||||||
#define REFRACTION @refraction_enabled
|
#define REFRACTION @refraction_enabled
|
||||||
#define SHADOWS @shadows_enabled
|
#define SHADOWS @shadows_enabled
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue