refactor GLSLExtension.cpp & add 'param' shader preprocessor directive & add PostEffect class (WIP)

This commit is contained in:
MihailRis
2025-04-03 21:46:12 +03:00
parent 531334f059
commit 1feee3a809
8 changed files with 263 additions and 97 deletions
+48 -22
View File
@@ -31,13 +31,9 @@ namespace {
}
template<typename CharT>
void BasicParser<CharT>::skipWhitespace(bool newline) {
if (hashComment) {
skipWhitespaceHashComment(newline);
return;
}
void BasicParser<CharT>::skipWhitespaceBasic(bool newline) {
while (hasNext()) {
char next = source[pos];
CharT next = source[pos];
if (next == '\n') {
if (!newline) {
break;
@@ -55,23 +51,20 @@ void BasicParser<CharT>::skipWhitespace(bool newline) {
}
template<typename CharT>
void BasicParser<CharT>::skipWhitespaceHashComment(bool newline) {
while (hasNext()) {
char next = source[pos];
if (next == '\n') {
if (!newline) {
break;
}
line++;
linestart = ++pos;
continue;
}
if (is_whitespace(next)) {
pos++;
} else {
break;
}
void BasicParser<CharT>::skipWhitespace(bool newline) {
if (hashComment) {
skipWhitespaceHashComment(newline);
return;
} else if (clikeComment) {
skipWhitespaceCLikeComment(newline);
return;
}
skipWhitespaceBasic(newline);
}
template<typename CharT>
void BasicParser<CharT>::skipWhitespaceHashComment(bool newline) {
skipWhitespaceBasic(newline);
if (hasNext() && source[pos] == '#') {
if (!newline) {
readUntilEOL();
@@ -84,6 +77,39 @@ void BasicParser<CharT>::skipWhitespaceHashComment(bool newline) {
}
}
template<typename CharT>
void BasicParser<CharT>::skipWhitespaceCLikeComment(bool newline) {
skipWhitespaceBasic(newline);
if (hasNext() && source[pos] == '/' && pos + 1 < source.length()) {
pos++;
switch (source[pos]) {
case '*':
pos++;
while (hasNext()) {
if (source[pos] == '/' && source[pos-1] == '*') {
pos++;
skipWhitespace();
return;
}
pos++;
}
break;
case '/':
if (!newline) {
readUntilEOL();
return;
}
skipLine();
if (hasNext() && (is_whitespace(source[pos]) || source[pos] == '/')) {
skipWhitespaceCLikeComment(newline);
}
default:
pos--;
break;
}
}
}
template<typename CharT>
void BasicParser<CharT>::skip(size_t n) {
n = std::min(n, source.length() - pos);