Use C++11 raw string literals instead of SHADER_SOURCE macro
This is better in many ways:
1. It doesn't confuse clang format
2. \n doesn't need to be included after preprocessor directives like
the version directive.
3. It's using built-in functionality instead of something custom.
Raw string literals should be the preferred way to include shader
source in C++ files going forward.
BUG=angleproject:2157
TEST=angle_end2end_tests
Change-Id: I8b236a6e2d5c25d920297e5bc5b5b143eddeba1f
Reviewed-on: https://chromium-review.googlesource.com/671046
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/tests/gl_tests/SimpleOperationTest.cpp b/src/tests/gl_tests/SimpleOperationTest.cpp
index a22b8e1..d5850d8 100644
--- a/src/tests/gl_tests/SimpleOperationTest.cpp
+++ b/src/tests/gl_tests/SimpleOperationTest.cpp
@@ -54,14 +54,12 @@
TEST_P(SimpleOperationTest, CompileVertexShader)
{
- const std::string source = SHADER_SOURCE
- (
- attribute vec4 a_input;
+ const std::string source =
+ R"(attribute vec4 a_input;
void main()
{
gl_Position = a_input;
- }
- );
+ })";
GLuint shader = CompileShader(GL_VERTEX_SHADER, source);
EXPECT_NE(shader, 0u);
@@ -72,15 +70,13 @@
TEST_P(SimpleOperationTest, CompileFragmentShader)
{
- const std::string source = SHADER_SOURCE
- (
- precision mediump float;
+ const std::string source =
+ R"(precision mediump float;
varying vec4 v_input;
void main()
{
gl_FragColor = v_input;
- }
- );
+ })";
GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
EXPECT_NE(shader, 0u);
@@ -91,21 +87,17 @@
TEST_P(SimpleOperationTest, LinkProgram)
{
- const std::string vsSource = SHADER_SOURCE
- (
- void main()
+ const std::string vsSource =
+ R"(void main()
{
gl_Position = vec4(1.0, 1.0, 1.0, 1.0);
- }
- );
+ })";
- const std::string fsSource = SHADER_SOURCE
- (
- void main()
+ const std::string fsSource =
+ R"(void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
- }
- );
+ })";
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_NE(program, 0u);
@@ -123,23 +115,19 @@
return;
}
- const std::string vsSource = SHADER_SOURCE
- (
- void main()
+ const std::string vsSource =
+ R"(void main()
{
gl_Position = vec4(1.0, 1.0, 1.0, 1.0);
- }
- );
+ })";
- const std::string fsSource = SHADER_SOURCE
- (
- precision mediump float;
+ const std::string fsSource =
+ R"(precision mediump float;
uniform vec4 u_input;
void main()
{
gl_FragColor = u_input;
- }
- );
+ })";
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_NE(program, 0u);
@@ -161,22 +149,18 @@
return;
}
- const std::string vsSource = SHADER_SOURCE
- (
- attribute vec4 a_input;
+ const std::string vsSource =
+ R"(attribute vec4 a_input;
void main()
{
gl_Position = a_input;
- }
- );
+ })";
- const std::string fsSource = SHADER_SOURCE
- (
- void main()
+ const std::string fsSource =
+ R"(void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
- }
- );
+ })";
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_NE(program, 0u);