mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-29 23:41:48 +00:00
- patch the token 'texture2d' in GLSL sources.
This builtin function no longer exists outside of backwards compatible GLSL compilers so it needs to be remapped to 'texture' so that user shaders still using it can compile.
This commit is contained in:
parent
ae57bc71d4
commit
9210811b74
1 changed files with 18 additions and 0 deletions
|
@ -116,6 +116,24 @@ FString RemoveLegacyUserUniforms(FString code)
|
|||
}
|
||||
}
|
||||
|
||||
// Also remove all occurences of the token 'texture2d'. Some shaders may still use this deprecated function to access a sampler.
|
||||
// Modern GLSL only allows use of 'texture'.
|
||||
while (true)
|
||||
{
|
||||
long matchIndex = code.IndexOf("texture2d", startIndex);
|
||||
if (matchIndex == -1)
|
||||
break;
|
||||
|
||||
// Check if this is a real token.
|
||||
bool isKeywordStart = matchIndex == 0 || !isalnum(chars[matchIndex - 1] & 255);
|
||||
bool isKeywordEnd = matchIndex + 9 == len || !isalnum(chars[matchIndex + 9] & 255);
|
||||
if (isKeywordStart && isKeywordEnd)
|
||||
{
|
||||
chars[matchIndex + 7] = chars[matchIndex + 8] = ' ';
|
||||
}
|
||||
startIndex = matchIndex + 9;
|
||||
}
|
||||
|
||||
code.UnlockBuffer();
|
||||
|
||||
return code;
|
||||
|
|
Loading…
Reference in a new issue