print warning for texture2d usage

This commit is contained in:
Ricardo Luís Vaz Silva 2025-04-16 13:18:37 -03:00
commit c0b6427b12

View file

@ -134,6 +134,8 @@ FString RemoveLegacyUserUniforms(FString code)
DPrintf(DMSG_WARNING, TEXTCOLOR_ORANGE "timer and tex uniforms should not be explicitly declared.\n");
}
bool foundtexture2d = false;
// 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)
@ -142,6 +144,8 @@ FString RemoveLegacyUserUniforms(FString code)
if (matchIndex == -1)
break;
foundtexture2d = true;
// 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);
@ -152,6 +156,11 @@ FString RemoveLegacyUserUniforms(FString code)
startIndex = matchIndex + 9;
}
if(foundtexture2d)
{
DPrintf(DMSG_WARNING, TEXTCOLOR_ORANGE "texture2d is deprecated, use texture instead.\n");
}
code.UnlockBuffer();
return code;