From 7fedb219df999ade85e132809f21e06c9aefd4e4 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Thu, 4 Aug 2022 15:09:01 +0900 Subject: [PATCH] [Shader Generator] Remove empty first line Trim the empty first line, so let the shader code start with "#version ~~~" Change-Id: I304f8690c66f66c3d90effcbc43b4ae895ba9691 Signed-off-by: Eunki, Hong --- dali-toolkit/shader-generator/shader-generator.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dali-toolkit/shader-generator/shader-generator.cpp b/dali-toolkit/shader-generator/shader-generator.cpp index a88333c..16cddcc 100644 --- a/dali-toolkit/shader-generator/shader-generator.cpp +++ b/dali-toolkit/shader-generator/shader-generator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,10 +144,21 @@ void GenerateHeaderFile( << endl; outFile << "const std::string_view " << shaderVariableName << endl; outFile << "{" << endl; - outFile << "R\"(" << endl; + + // Using Raw String Literal to generate shader files as this will simplify the file layout. + // And it will fix some compilation warnings about missing terminating strings. + // Note : we should skip empty headline to guarantee that "#version ~~~" as top of shader code. + outFile << "R\"("; string line; + bool firstLinePrinted = false; while(getline(shaderFile, line)) { + if(!firstLinePrinted && line.find_first_not_of(" \t\r\n") == std::string::npos) + { + // Empty string occured! + continue; + } + firstLinePrinted = true; outFile << line << endl; } outFile << ")\"" << endl; -- 2.7.4