From c769a3915f80eff6fafab009a260ddb536a1817c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= <tomi.korpipaa@digia.com>
Date: Fri, 24 Oct 2014 07:17:00 +0300
Subject: [PATCH] Use proper multiline strings for shader strings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Added to the rest of the examples. Causes crashing on Qt5.4 Beta without
them.

Change-Id: I7b060ccdfd5458057dd3053ca40d8569aef89dd2
Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
---
 .../canvasswitch/qml/canvasswitch/cube.js     | 18 +++---
 .../canvasswitch/qml/canvasswitch/triangle.js | 10 +--
 .../qml/framebuffer/framebuffer.js            | 62 +++++++++----------
 examples/canvas3d/jsonmodels/jsonmodels.js    | 56 ++++++++---------
 4 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js b/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js
index a738df1..cd2ee2f 100644
--- a/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js
+++ b/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js
@@ -162,17 +162,17 @@ function initShaders() {
     log("    Initializing shaders...");
 
     vertexShader = getShader(gl, "attribute highp vec3 aVertexPosition; \
-                                  attribute highp vec4 aVertexColor; \
-                                  uniform highp mat4 uMVMatrix; \
-                                  uniform highp mat4 uPMatrix; \
-                                  varying highp vec4 vColor; \
-                                  void main(void) { \
+                                  attribute highp vec4 aVertexColor;    \
+                                  uniform highp mat4 uMVMatrix;         \
+                                  uniform highp mat4 uPMatrix;          \
+                                  varying highp vec4 vColor;            \
+                                  void main(void) {                     \
                                       gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); \
-                                      vColor = aVertexColor; \
+                                      vColor = aVertexColor;            \
                                   }", gl.VERTEX_SHADER);
-    fragmentShader = getShader(gl, "varying highp vec4 vColor; \
-                                    void main(void) { \
-                                        gl_FragColor = vColor; \
+    fragmentShader = getShader(gl, "varying highp vec4 vColor;  \
+                                    void main(void) {           \
+                                        gl_FragColor = vColor;  \
                                     }", gl.FRAGMENT_SHADER);
 
     shaderProgram = gl.createProgram();
diff --git a/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js b/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js
index 08052ab..46e1b52 100644
--- a/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js
+++ b/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js
@@ -73,12 +73,12 @@ function renderGL(canvas) {
 function initShaders()
 {
     // setup a GLSL program
-    vertexShader = compileShader("attribute vec2 a_position; \
-                                  void main() { \
-                                      gl_Position = vec4(a_position, 0.0, 1.0); \
+    vertexShader = compileShader("attribute vec2 a_position;                        \
+                                  void main() {                                     \
+                                      gl_Position = vec4(a_position, 0.0, 1.0);     \
                                  }", gl.VERTEX_SHADER);
-    fragmentShader = compileShader("void main() { \
-                                        gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); \
+    fragmentShader = compileShader("void main() {                                   \
+                                        gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);    \
                                    }", gl.FRAGMENT_SHADER);
 
     shaderProgram = gl.createProgram();
diff --git a/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js b/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js
index f2718c1..6988009 100644
--- a/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js
+++ b/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js
@@ -374,41 +374,41 @@ function initBuffers()
 function initShaders()
 {
     var vertexShader = getShader(gl,
-                                 "attribute highp vec3 aVertexNormal;
-                                  attribute highp vec3 aVertexPosition;
-                                  attribute mediump vec4 aVertexColor;
-                                  attribute highp vec2 aTextureCoord;
-
-                                  uniform highp mat4 uNormalMatrix;
-                                  uniform mat4 uMVMatrix;
-                                  uniform mat4 uPMatrix;
-
-                                  varying mediump vec4 vColor;
-                                  varying highp vec2 vTextureCoord;
-                                  varying highp vec3 vLighting;
-
-                                  void main(void) {
-                                      gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
-                                      vColor = aVertexColor;
-                                      vTextureCoord = aTextureCoord;
-                                      highp vec3 ambientLight = vec3(0.5, 0.5, 0.5);
-                                      highp vec3 directionalLightColor = vec3(0.75, 0.75, 0.75);
-                                      highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);
-                                      highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
-                                      highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
-                                      vLighting = ambientLight + (directionalLightColor * directional);
+                                 "attribute highp vec3 aVertexNormal;   \
+                                  attribute highp vec3 aVertexPosition; \
+                                  attribute mediump vec4 aVertexColor;  \
+                                  attribute highp vec2 aTextureCoord;   \
+
+                                  uniform highp mat4 uNormalMatrix;     \
+                                  uniform mat4 uMVMatrix;               \
+                                  uniform mat4 uPMatrix;                \
+
+                                  varying mediump vec4 vColor;          \
+                                  varying highp vec2 vTextureCoord;     \
+                                  varying highp vec3 vLighting;         \
+
+                                  void main(void) {                     \
+                                      gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);                      \
+                                      vColor = aVertexColor;                                                                \
+                                      vTextureCoord = aTextureCoord;                                                        \
+                                      highp vec3 ambientLight = vec3(0.5, 0.5, 0.5);                                        \
+                                      highp vec3 directionalLightColor = vec3(0.75, 0.5, 0.75);                             \
+                                      highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);                                 \
+                                      highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);              \
+                                      highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);    \
+                                      vLighting = ambientLight + (directionalLightColor * directional);                     \
                                   }", gl.VERTEX_SHADER);
     var fragmentShader = getShader(gl,
-                                   "varying mediump vec4 vColor;
-                                    varying highp vec2 vTextureCoord;
-                                    varying highp vec3 vLighting;
+                                   "varying mediump vec4 vColor;        \
+                                    varying highp vec2 vTextureCoord;   \
+                                    varying highp vec3 vLighting;       \
 
-                                    uniform sampler2D uSampler;
+                                    uniform sampler2D uSampler;         \
 
-                                    void main(void) {
-                                        mediump vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
-                                        mediump vec3 blendColor = mix(vColor.rgb, texelColor.rgb, texelColor.a);
-                                        gl_FragColor = vec4(blendColor * vLighting, 1.0);
+                                    void main(void) {                   \
+                                        mediump vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));  \
+                                        mediump vec3 blendColor = mix(vColor.rgb, texelColor.rgb, texelColor.a);                \
+                                        gl_FragColor = vec4(blendColor * vLighting, 1.0);                                       \
                                     }", gl.FRAGMENT_SHADER);
 
     var shaderProgram = gl.createProgram();
diff --git a/examples/canvas3d/jsonmodels/jsonmodels.js b/examples/canvas3d/jsonmodels/jsonmodels.js
index aee7a1c..254ae50 100644
--- a/examples/canvas3d/jsonmodels/jsonmodels.js
+++ b/examples/canvas3d/jsonmodels/jsonmodels.js
@@ -654,39 +654,39 @@ function initShaders()
     log("   initShaders...")
 
     vertexShader = getShader(gl,
-                             "attribute highp vec3 aVertexNormal;
-                              attribute highp vec3 aVertexPosition;
-                              attribute highp vec2 aTextureCoord;
-
-                              uniform highp mat4 uNormalMatrix;
-                              uniform mat4 uMVMatrix;
-                              uniform mat4 uPMatrix;
-                              uniform vec3 eyePos;
-
-                              varying highp vec2 vTextureCoord;
-                              varying highp vec4 vLighting;
-
-                              void main(void) {
-                                 gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
-                                 vTextureCoord = aTextureCoord;
-                                 highp vec4 ambientLight = vec4(0.5, 0.5, 0.5, 1.0);
-                                 highp vec4 directionalLightColor = vec4(1.0, 1.0, 1.0, 1.0);
-                                 highp vec3 directionalVector = eyePos;
-                                 highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
-
-                                 highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
-                                 vLighting = ambientLight + (directionalLightColor * directional);
+                             "attribute highp vec3 aVertexNormal;   \
+                              attribute highp vec3 aVertexPosition; \
+                              attribute highp vec2 aTextureCoord;   \
+
+                              uniform highp mat4 uNormalMatrix;     \
+                              uniform mat4 uMVMatrix;               \
+                              uniform mat4 uPMatrix;                \
+                              uniform vec3 eyePos;                  \
+
+                              varying highp vec2 vTextureCoord;     \
+                              varying highp vec4 vLighting;         \
+
+                              void main(void) {                     \
+                                 gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);                   \
+                                 vTextureCoord = aTextureCoord;                                                     \
+                                 highp vec4 ambientLight = vec4(0.5, 0.5, 0.5, 1.0);                                \
+                                 highp vec4 directionalLightColor = vec4(1.0, 1.0, 1.0, 1.0);                       \
+                                 highp vec3 directionalVector = eyePos;                                             \
+                                 highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);           \
+
+                                 highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0); \
+                                 vLighting = ambientLight + (directionalLightColor * directional);                  \
                              }", gl.VERTEX_SHADER);
 
     fragmentShader = getShader(gl,
-                               "varying highp vec2 vTextureCoord;
-                                varying highp vec4 vLighting;
+                               "varying highp vec2 vTextureCoord;   \
+                                varying highp vec4 vLighting;       \
 
-                                uniform sampler2D uSampler;
+                                uniform sampler2D uSampler;         \
 
-                                void main(void) {
-                                    mediump vec4 texelColor = texture2D(uSampler, vTextureCoord);
-                                    gl_FragColor = vec4(texelColor * vLighting);
+                                void main(void) {                   \
+                                    mediump vec4 texelColor = texture2D(uSampler, vTextureCoord);   \
+                                    gl_FragColor = vec4(texelColor * vLighting);                    \
                                 }", gl.FRAGMENT_SHADER);
 
     texturedShaderProgram = gl.createProgram();
-- 
GitLab