mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Fix]: (MG_Util/ShaderTranspiler/ShaderSourceProcessor): fix trailing \n not get removed
This commit is contained in:
@@ -4,14 +4,6 @@ namespace MobileGL {
|
|||||||
namespace MG_Util {
|
namespace MG_Util {
|
||||||
namespace ShaderTranspiler {
|
namespace ShaderTranspiler {
|
||||||
void PreprocessShaderSource(ShaderStage stage, String& source) {
|
void PreprocessShaderSource(ShaderStage stage, String& source) {
|
||||||
// remove #line directives
|
|
||||||
SizeT linedirPos = source.find("#line");
|
|
||||||
while (linedirPos != std::string::npos) {
|
|
||||||
SizeT newlinePos = source.find('\n', linedirPos);
|
|
||||||
source = source.replace(linedirPos, newlinePos - linedirPos, "");
|
|
||||||
linedirPos = source.find("#line", linedirPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove multi-line comment
|
// remove multi-line comment
|
||||||
size_t commentStartPos = source.find("/*");
|
size_t commentStartPos = source.find("/*");
|
||||||
while (commentStartPos != std::string::npos) {
|
while (commentStartPos != std::string::npos) {
|
||||||
@@ -21,6 +13,15 @@ namespace MobileGL {
|
|||||||
commentStartPos = source.find("/*", commentStartPos);
|
commentStartPos = source.find("/*", commentStartPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove #line directives
|
||||||
|
SizeT linedirPos = source.find("#line");
|
||||||
|
while (linedirPos != std::string::npos) {
|
||||||
|
SizeT newlinePos = source.find('\n', linedirPos);
|
||||||
|
// + length of "\n"
|
||||||
|
source = source.replace(linedirPos, newlinePos - linedirPos + 1, "");
|
||||||
|
linedirPos = source.find("#line", linedirPos);
|
||||||
|
}
|
||||||
|
|
||||||
// force #version
|
// force #version
|
||||||
ShaderProfile profile = ShaderProfile::Core;
|
ShaderProfile profile = ShaderProfile::Core;
|
||||||
SizeT versionPos = source.find("#version");
|
SizeT versionPos = source.find("#version");
|
||||||
|
|||||||
Reference in New Issue
Block a user