From 1c78303280e61ef79c6bf1d36c700b8fabedc92f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= <tomi.korpipaa@digia.com>
Date: Mon, 22 Sep 2014 09:27:49 +0300
Subject: [PATCH] Updated examples
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Previous commit changed the way textures are loaded, so an update is
needed to examples that use textures.

Change-Id: I18c0d9e8dac555d2dc5012ca6477b9e515c5e82f
Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
---
 examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js     | 1 +
 examples/canvas3d/interaction/qml/interaction/interaction.js     | 1 +
 examples/canvas3d/jsonmodels/jsonmodels.js                       | 1 +
 .../canvas3d/plasmaeffects/qml/plasmaeffects/plasmaeffects.js    | 1 +
 .../textureandlight/qml/textureandlight/textureandlight.js       | 1 +
 examples/canvas3d/texturedcube/qml/texturedcube/texturedcube.js  | 1 +
 6 files changed, 6 insertions(+)

diff --git a/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js b/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js
index b58b34f..f2718c1 100644
--- a/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js
+++ b/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js
@@ -46,6 +46,7 @@ function initGL(canvas, textureLoader) {
         gl.cullFace(gl.BACK);
         gl.enable(gl.DEPTH_WRITE);
         gl.depthMask(true);
+        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
 
         // Initialize the shader program
         initShaders();
diff --git a/examples/canvas3d/interaction/qml/interaction/interaction.js b/examples/canvas3d/interaction/qml/interaction/interaction.js
index 933c6e4..90c2159 100644
--- a/examples/canvas3d/interaction/qml/interaction/interaction.js
+++ b/examples/canvas3d/interaction/qml/interaction/interaction.js
@@ -94,6 +94,7 @@ function initGL(canvas, textureLoader) {
         theModel.indexVBO.name = "BarrelModel.indexVBO";
 
         // Load the barrel texture
+        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
         textureLoader.loadImage("qrc:/qml/interaction/barrel.jpg");
 
         // Load the model
diff --git a/examples/canvas3d/jsonmodels/jsonmodels.js b/examples/canvas3d/jsonmodels/jsonmodels.js
index 1d2cd8b..aee7a1c 100644
--- a/examples/canvas3d/jsonmodels/jsonmodels.js
+++ b/examples/canvas3d/jsonmodels/jsonmodels.js
@@ -114,6 +114,7 @@ function initGL(canvas, textureLoader) {
         initBuffers();
 
         // Load textures
+        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
         loadTextures(textureLoader);
 
         // Load JSON models
diff --git a/examples/canvas3d/plasmaeffects/qml/plasmaeffects/plasmaeffects.js b/examples/canvas3d/plasmaeffects/qml/plasmaeffects/plasmaeffects.js
index 4848de7..99683a4 100644
--- a/examples/canvas3d/plasmaeffects/qml/plasmaeffects/plasmaeffects.js
+++ b/examples/canvas3d/plasmaeffects/qml/plasmaeffects/plasmaeffects.js
@@ -61,6 +61,7 @@ function initGL(canvas, textureLoader) {
         gl.enable(gl.CULL_FACE);
         gl.cullFace(gl.BACK);
         gl.disable(gl.BLEND);
+        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
 
         // Set viewport
         gl.viewport(0, 0, canvas.width * canvas.devicePixelRatio,
diff --git a/examples/canvas3d/textureandlight/qml/textureandlight/textureandlight.js b/examples/canvas3d/textureandlight/qml/textureandlight/textureandlight.js
index 24f4abc..62f0bb7 100644
--- a/examples/canvas3d/textureandlight/qml/textureandlight/textureandlight.js
+++ b/examples/canvas3d/textureandlight/qml/textureandlight/textureandlight.js
@@ -38,6 +38,7 @@ function initGL(canvas, textureLoader) {
     gl.cullFace(gl.BACK);
     gl.clearColor(0.0, 0.0, 0.0, 1.0);
     gl.clearDepth(1.0);
+    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
     //! [2]
 
     // Set viewport
diff --git a/examples/canvas3d/texturedcube/qml/texturedcube/texturedcube.js b/examples/canvas3d/texturedcube/qml/texturedcube/texturedcube.js
index a0e790f..6df51a8 100644
--- a/examples/canvas3d/texturedcube/qml/texturedcube/texturedcube.js
+++ b/examples/canvas3d/texturedcube/qml/texturedcube/texturedcube.js
@@ -42,6 +42,7 @@ function initGL(canvas, textureLoader) {
     gl.clearColor(0.0, 0.0, 0.0, 1.0);
     gl.clearDepth(1.0);
     gl.depthFunc(gl.LESS);
+    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
 
     // Set the viewport
     gl.viewport(0, 0, canvas.width, canvas.height);
-- 
GitLab