summaryrefslogtreecommitdiff
path: root/slideshow/opengl
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2015-12-21 21:25:35 +0000
committerToma┼ż Vajngerl <tomaz.vajngerl@collabora.com>2016-01-05 15:05:49 +0100
commita301da7cb6c562cd21983d9b3b34dc01235a82a5 (patch)
treeafc78dbfadabc23486c7c7037b614574c06afcf6 /slideshow/opengl
parentd886fef25c5978dd4b07fa0e3ce2402874a6c29a (diff)
slideshow: Define inverse() to bring back the GLSL version to 1.20
Change-Id: Ib0372d6a98734724d99b979f2d01abc1ee317847
Diffstat (limited to 'slideshow/opengl')
-rw-r--r--slideshow/opengl/basicVertexShader.glsl45
-rw-r--r--slideshow/opengl/glitterFragmentShader.glsl2
-rw-r--r--slideshow/opengl/glitterVertexShader.glsl45
-rw-r--r--slideshow/opengl/reflectionVertexShader.glsl45
-rw-r--r--slideshow/opengl/vortexVertexShader.glsl45
5 files changed, 177 insertions, 5 deletions
diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl
index e9febfff5b16..730da36fd67b 100644
--- a/slideshow/opengl/basicVertexShader.glsl
+++ b/slideshow/opengl/basicVertexShader.glsl
@@ -26,7 +26,7 @@
*
************************************************************************/
-#version 140
+#version 120
attribute vec3 a_position;
attribute vec3 a_normal;
@@ -41,6 +41,49 @@ uniform mat4 u_operationsTransformMatrix;
varying vec2 v_texturePosition;
varying vec3 v_normal;
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+ float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+ float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+ float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+ float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+ float b00 = a00 * a11 - a01 * a10;
+ float b01 = a00 * a12 - a02 * a10;
+ float b02 = a00 * a13 - a03 * a10;
+ float b03 = a01 * a12 - a02 * a11;
+ float b04 = a01 * a13 - a03 * a11;
+ float b05 = a02 * a13 - a03 * a12;
+ float b06 = a20 * a31 - a21 * a30;
+ float b07 = a20 * a32 - a22 * a30;
+ float b08 = a20 * a33 - a23 * a30;
+ float b09 = a21 * a32 - a22 * a31;
+ float b10 = a21 * a33 - a23 * a31;
+ float b11 = a22 * a33 - a23 * a32;
+
+ float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+ return mat4(
+ a11 * b11 - a12 * b10 + a13 * b09,
+ a02 * b10 - a01 * b11 - a03 * b09,
+ a31 * b05 - a32 * b04 + a33 * b03,
+ a22 * b04 - a21 * b05 - a23 * b03,
+ a12 * b08 - a10 * b11 - a13 * b07,
+ a00 * b11 - a02 * b08 + a03 * b07,
+ a32 * b02 - a30 * b05 - a33 * b01,
+ a20 * b05 - a22 * b02 + a23 * b01,
+ a10 * b10 - a11 * b08 + a13 * b06,
+ a01 * b08 - a00 * b10 - a03 * b06,
+ a30 * b04 - a31 * b02 + a33 * b00,
+ a21 * b02 - a20 * b04 - a23 * b00,
+ a11 * b07 - a10 * b09 - a12 * b06,
+ a00 * b09 - a01 * b07 + a02 * b06,
+ a31 * b01 - a30 * b03 - a32 * b00,
+ a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
void main( void )
{
mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
diff --git a/slideshow/opengl/glitterFragmentShader.glsl b/slideshow/opengl/glitterFragmentShader.glsl
index 1bec20102be6..71881742c7ea 100644
--- a/slideshow/opengl/glitterFragmentShader.glsl
+++ b/slideshow/opengl/glitterFragmentShader.glsl
@@ -7,7 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#version 130
+#version 120
#define M_PI 3.1415926535897932384626433832795
diff --git a/slideshow/opengl/glitterVertexShader.glsl b/slideshow/opengl/glitterVertexShader.glsl
index 64bb6debb8ae..3704efdab90e 100644
--- a/slideshow/opengl/glitterVertexShader.glsl
+++ b/slideshow/opengl/glitterVertexShader.glsl
@@ -7,7 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#version 140
+#version 120
#define M_PI 3.1415926535897932384626433832795
@@ -29,6 +29,49 @@ uniform ivec2 numTiles;
uniform sampler2D permTexture;
varying float angle;
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+ float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+ float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+ float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+ float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+ float b00 = a00 * a11 - a01 * a10;
+ float b01 = a00 * a12 - a02 * a10;
+ float b02 = a00 * a13 - a03 * a10;
+ float b03 = a01 * a12 - a02 * a11;
+ float b04 = a01 * a13 - a03 * a11;
+ float b05 = a02 * a13 - a03 * a12;
+ float b06 = a20 * a31 - a21 * a30;
+ float b07 = a20 * a32 - a22 * a30;
+ float b08 = a20 * a33 - a23 * a30;
+ float b09 = a21 * a32 - a22 * a31;
+ float b10 = a21 * a33 - a23 * a31;
+ float b11 = a22 * a33 - a23 * a32;
+
+ float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+ return mat4(
+ a11 * b11 - a12 * b10 + a13 * b09,
+ a02 * b10 - a01 * b11 - a03 * b09,
+ a31 * b05 - a32 * b04 + a33 * b03,
+ a22 * b04 - a21 * b05 - a23 * b03,
+ a12 * b08 - a10 * b11 - a13 * b07,
+ a00 * b11 - a02 * b08 + a03 * b07,
+ a32 * b02 - a30 * b05 - a33 * b01,
+ a20 * b05 - a22 * b02 + a23 * b01,
+ a10 * b10 - a11 * b08 + a13 * b06,
+ a01 * b08 - a00 * b10 - a03 * b06,
+ a30 * b04 - a31 * b02 + a33 * b00,
+ a21 * b02 - a20 * b04 - a23 * b00,
+ a11 * b07 - a10 * b09 - a12 * b06,
+ a00 * b09 - a01 * b07 + a02 * b06,
+ a31 * b01 - a30 * b03 - a32 * b00,
+ a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
float snoise(vec2 p)
{
return texture2D(permTexture, p).r;
diff --git a/slideshow/opengl/reflectionVertexShader.glsl b/slideshow/opengl/reflectionVertexShader.glsl
index c7e6b5806341..a0bcc27eb5aa 100644
--- a/slideshow/opengl/reflectionVertexShader.glsl
+++ b/slideshow/opengl/reflectionVertexShader.glsl
@@ -26,7 +26,7 @@
*
************************************************************************/
-#version 140
+#version 130
attribute vec3 a_position;
attribute vec3 a_normal;
@@ -42,6 +42,49 @@ varying vec2 v_texturePosition;
varying vec3 v_normal;
varying float v_isShadow;
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+ float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+ float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+ float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+ float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+ float b00 = a00 * a11 - a01 * a10;
+ float b01 = a00 * a12 - a02 * a10;
+ float b02 = a00 * a13 - a03 * a10;
+ float b03 = a01 * a12 - a02 * a11;
+ float b04 = a01 * a13 - a03 * a11;
+ float b05 = a02 * a13 - a03 * a12;
+ float b06 = a20 * a31 - a21 * a30;
+ float b07 = a20 * a32 - a22 * a30;
+ float b08 = a20 * a33 - a23 * a30;
+ float b09 = a21 * a32 - a22 * a31;
+ float b10 = a21 * a33 - a23 * a31;
+ float b11 = a22 * a33 - a23 * a32;
+
+ float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+ return mat4(
+ a11 * b11 - a12 * b10 + a13 * b09,
+ a02 * b10 - a01 * b11 - a03 * b09,
+ a31 * b05 - a32 * b04 + a33 * b03,
+ a22 * b04 - a21 * b05 - a23 * b03,
+ a12 * b08 - a10 * b11 - a13 * b07,
+ a00 * b11 - a02 * b08 + a03 * b07,
+ a32 * b02 - a30 * b05 - a33 * b01,
+ a20 * b05 - a22 * b02 + a23 * b01,
+ a10 * b10 - a11 * b08 + a13 * b06,
+ a01 * b08 - a00 * b10 - a03 * b06,
+ a30 * b04 - a31 * b02 + a33 * b00,
+ a21 * b02 - a20 * b04 - a23 * b00,
+ a11 * b07 - a10 * b09 - a12 * b06,
+ a00 * b09 - a01 * b07 + a02 * b06,
+ a31 * b01 - a30 * b03 - a32 * b00,
+ a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
void main( void )
{
mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
index 226d6fd36f9e..e01b3316e598 100644
--- a/slideshow/opengl/vortexVertexShader.glsl
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -7,7 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#version 140
+#version 120
#define M_PI 3.1415926535897932384626433832795
@@ -32,6 +32,49 @@ uniform float slide;
varying vec4 debug;
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+ float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+ float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+ float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+ float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+ float b00 = a00 * a11 - a01 * a10;
+ float b01 = a00 * a12 - a02 * a10;
+ float b02 = a00 * a13 - a03 * a10;
+ float b03 = a01 * a12 - a02 * a11;
+ float b04 = a01 * a13 - a03 * a11;
+ float b05 = a02 * a13 - a03 * a12;
+ float b06 = a20 * a31 - a21 * a30;
+ float b07 = a20 * a32 - a22 * a30;
+ float b08 = a20 * a33 - a23 * a30;
+ float b09 = a21 * a32 - a22 * a31;
+ float b10 = a21 * a33 - a23 * a31;
+ float b11 = a22 * a33 - a23 * a32;
+
+ float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+ return mat4(
+ a11 * b11 - a12 * b10 + a13 * b09,
+ a02 * b10 - a01 * b11 - a03 * b09,
+ a31 * b05 - a32 * b04 + a33 * b03,
+ a22 * b04 - a21 * b05 - a23 * b03,
+ a12 * b08 - a10 * b11 - a13 * b07,
+ a00 * b11 - a02 * b08 + a03 * b07,
+ a32 * b02 - a30 * b05 - a33 * b01,
+ a20 * b05 - a22 * b02 + a23 * b01,
+ a10 * b10 - a11 * b08 + a13 * b06,
+ a01 * b08 - a00 * b10 - a03 * b06,
+ a30 * b04 - a31 * b02 + a33 * b00,
+ a21 * b02 - a20 * b04 - a23 * b00,
+ a11 * b07 - a10 * b09 - a12 * b06,
+ a00 * b09 - a01 * b07 + a02 * b06,
+ a31 * b01 - a30 * b03 - a32 * b00,
+ a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
float snoise(vec2 p)
{
return texture2D(permTexture, p).r;