diff options
-rw-r--r-- | slideshow/opengl/basicVertexShader.glsl | 2 | ||||
-rw-r--r-- | slideshow/opengl/dissolveFragmentShader.glsl | 2 | ||||
-rw-r--r-- | slideshow/opengl/rippleFragmentShader.glsl | 2 | ||||
-rw-r--r-- | slideshow/opengl/staticFragmentShader.glsl | 2 | ||||
-rwxr-xr-x | slideshow/opengl/vortexFragmentShader.glsl | 2 | ||||
-rwxr-xr-x | slideshow/opengl/vortexVertexShader.glsl | 17 | ||||
-rw-r--r-- | slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx | 107 |
7 files changed, 40 insertions, 94 deletions
diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl index 4ca615a57689..da8355465f9d 100644 --- a/slideshow/opengl/basicVertexShader.glsl +++ b/slideshow/opengl/basicVertexShader.glsl @@ -26,6 +26,8 @@ * ************************************************************************/ +#version 120 + varying vec2 v_texturePosition; void main( void ) diff --git a/slideshow/opengl/dissolveFragmentShader.glsl b/slideshow/opengl/dissolveFragmentShader.glsl index c6e80e2a6931..6ce3d539d114 100644 --- a/slideshow/opengl/dissolveFragmentShader.glsl +++ b/slideshow/opengl/dissolveFragmentShader.glsl @@ -26,6 +26,8 @@ * ************************************************************************/ +#version 120 + uniform sampler2D leavingSlideTexture; uniform sampler2D enteringSlideTexture; uniform sampler2D permTexture; diff --git a/slideshow/opengl/rippleFragmentShader.glsl b/slideshow/opengl/rippleFragmentShader.glsl index 83677e4d6390..ac6b8ac37099 100644 --- a/slideshow/opengl/rippleFragmentShader.glsl +++ b/slideshow/opengl/rippleFragmentShader.glsl @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#version 120 + #define M_PI 3.1415926535897932384626433832795 uniform sampler2D leavingSlideTexture; diff --git a/slideshow/opengl/staticFragmentShader.glsl b/slideshow/opengl/staticFragmentShader.glsl index cd47c5ad6fd7..ab4913de766c 100644 --- a/slideshow/opengl/staticFragmentShader.glsl +++ b/slideshow/opengl/staticFragmentShader.glsl @@ -26,6 +26,8 @@ * ************************************************************************/ +#version 120 + uniform sampler2D leavingSlideTexture; uniform sampler2D enteringSlideTexture; uniform sampler2D permTexture; diff --git a/slideshow/opengl/vortexFragmentShader.glsl b/slideshow/opengl/vortexFragmentShader.glsl index a8a976731034..9b7741acb100 100755 --- a/slideshow/opengl/vortexFragmentShader.glsl +++ b/slideshow/opengl/vortexFragmentShader.glsl @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#version 120 + uniform sampler2D leavingSlideTexture; uniform sampler2D enteringSlideTexture; uniform float time; diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl index 532260d748a9..1dffbbd187df 100755 --- a/slideshow/opengl/vortexVertexShader.glsl +++ b/slideshow/opengl/vortexVertexShader.glsl @@ -7,15 +7,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#version 120 + #define M_PI 3.1415926535897932384626433832795 uniform float time; uniform ivec2 numTiles; uniform sampler2D permTexture; -attribute vec2 tileCenter; -attribute int tileXIndex; -attribute int tileYIndex; -attribute int vertexIndexInTile; +attribute float tileInfo; varying vec2 v_texturePosition; varying float v_textureSelect; @@ -52,9 +51,17 @@ void main( void ) // at time=0.5, when the tiles there (the rightmost ones) start // moving. + // In GLSL 1.20 we don't have any bitwise operators, sigh + + int tileXIndex = int(mod(int(tileInfo), 256)); + int tileYIndex = int(mod(int(tileInfo) / 256, 256)); + int vertexIndexInTile = int(mod(int(tileInfo) / (256*256), 256)); + float startTime = float(tileXIndex)/(numTiles.x-1) * 0.5; float endTime = startTime + 0.5; + vec2 tileCenter = vec2(-1 + 1.5 * tileXIndex * (2.0/numTiles.x), -1 + 1.5 * tileYIndex * (2.0/numTiles.y)); + if (time <= startTime) { // Still at start location, nothing needed @@ -86,7 +93,7 @@ void main( void ) v.z += (fuzz < 0.5 ? -1 : 1) * tileCenter.x * sin(moveTime*M_PI); // Perturb z a bit randomly - v.z += ((((tileXIndex << 3) ^ tileYIndex) % 10) - 5) * (1 - abs(time-0.5)*2); + v.z += (fuzz - 0.5) * 5 * (1 - abs(time-0.5)*2); v_textureSelect = float(rotation > 0.5); } diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx index fd3e73f1f9cd..f3897e7974b6 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx @@ -1659,20 +1659,11 @@ class VortexTransition : public ShaderTransition public: VortexTransition(const TransitionScene& rScene, const TransitionSettings& rSettings, int nNX, int nNY) : ShaderTransition(rScene, rSettings) - , mnTileCenterLocation(0) - , mnTileXIndexLocation(0) - , mnTileYIndexLocation(0) - , mnVertexIndexInTileLocation(0) - , mnTileCenterBuffer(0) - , mnTileXIndexBuffer(0) - , mnTileYIndexBuffer(0) - , mnVertexIndexInTileBuffer(0) + , mnTileInfoLocation(0) + , mnTileInfoBuffer(0) , maNumTiles(nNX,nNY) { - mvTileCenters.resize(6*maNumTiles.x*maNumTiles.y); - mvTileXIndexes.resize(6*maNumTiles.x*maNumTiles.y); - mvTileYIndexes.resize(6*maNumTiles.x*maNumTiles.y); - mvVertexIndexesInTiles.resize(6*maNumTiles.x*maNumTiles.y); + mvTileInfo.resize(6*maNumTiles.x*maNumTiles.y); } private: @@ -1682,53 +1673,23 @@ private: virtual GLuint makeShader() override; - GLint mnTileCenterLocation; - GLint mnTileXIndexLocation; - GLint mnTileYIndexLocation; - GLint mnVertexIndexInTileLocation; - GLuint mnTileCenterBuffer; - GLuint mnTileXIndexBuffer; - GLuint mnTileYIndexBuffer; - GLuint mnVertexIndexInTileBuffer; + GLint mnTileInfoLocation; + GLuint mnTileInfoBuffer; glm::ivec2 maNumTiles; - std::vector<glm::vec2> mvTileCenters; - std::vector<GLint> mvTileXIndexes; - std::vector<GLint> mvTileYIndexes; - std::vector<GLint> mvVertexIndexesInTiles; + std::vector<GLfloat> mvTileInfo; }; void VortexTransition::prepare( double, double, double, double, double ) { glDisable(GL_CULL_FACE); - glBindBuffer(GL_ARRAY_BUFFER, mnTileCenterBuffer); + glBindBuffer(GL_ARRAY_BUFFER, mnTileInfoBuffer); CHECK_GL_ERROR(); - glEnableVertexAttribArray(mnTileCenterLocation); + glEnableVertexAttribArray(mnTileInfoLocation); CHECK_GL_ERROR(); - glVertexAttribPointer(mnTileCenterLocation, 2, GL_FLOAT, GL_FALSE, 0, 0); - CHECK_GL_ERROR(); - - glBindBuffer(GL_ARRAY_BUFFER, mnTileXIndexBuffer); - CHECK_GL_ERROR(); - glEnableVertexAttribArray(mnTileXIndexLocation); - CHECK_GL_ERROR(); - glVertexAttribIPointer(mnTileXIndexLocation, 1, GL_INT, 0, 0); - CHECK_GL_ERROR(); - - glBindBuffer(GL_ARRAY_BUFFER, mnTileYIndexBuffer); - CHECK_GL_ERROR(); - glEnableVertexAttribArray(mnTileYIndexLocation); - CHECK_GL_ERROR(); - glVertexAttribIPointer(mnTileYIndexLocation, 1, GL_INT, 0, 0); - CHECK_GL_ERROR(); - - glBindBuffer(GL_ARRAY_BUFFER, mnVertexIndexInTileBuffer); - CHECK_GL_ERROR(); - glEnableVertexAttribArray(mnVertexIndexInTileLocation); - CHECK_GL_ERROR(); - glVertexAttribIPointer(mnVertexIndexInTileLocation, 1, GL_INT, 0, 0); + glVertexAttribPointer(mnTileInfoLocation, 1, GL_FLOAT, GL_FALSE, 0, 0); CHECK_GL_ERROR(); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -1746,13 +1707,7 @@ GLuint VortexTransition::makeShader() if (nProgram) { - mnTileCenterLocation = glGetAttribLocation(nProgram, "tileCenter"); - CHECK_GL_ERROR(); - mnTileXIndexLocation = glGetAttribLocation(nProgram, "tileXIndex"); - CHECK_GL_ERROR(); - mnTileYIndexLocation = glGetAttribLocation(nProgram, "tileYIndex"); - CHECK_GL_ERROR(); - mnVertexIndexInTileLocation = glGetAttribLocation(nProgram, "vertexIndexInTile"); + mnTileInfoLocation = glGetAttribLocation(nProgram, "tileInfo"); CHECK_GL_ERROR(); glUseProgram(nProgram); @@ -1765,15 +1720,13 @@ GLuint VortexTransition::makeShader() CHECK_GL_ERROR(); } - glGenBuffers(1, &mnTileCenterBuffer); - CHECK_GL_ERROR(); - glGenBuffers(1, &mnTileXIndexBuffer); - CHECK_GL_ERROR(); - glGenBuffers(1, &mnTileYIndexBuffer); - CHECK_GL_ERROR(); - glGenBuffers(1, &mnVertexIndexInTileBuffer); + glGenBuffers(1, &mnTileInfoBuffer); CHECK_GL_ERROR(); + // We store the (x,y) indexes of the tile each vertex belongs to in a float, so they must fit. + assert(maNumTiles.x < 256); + assert(maNumTiles.y < 256); + // Two triangles, i.e. six vertices, per tile { int n = 0; @@ -1783,40 +1736,16 @@ GLuint VortexTransition::makeShader() { for (int v = 0; v < 6; v++) { - // Note that Primitive::pushTriangle() has mapped the coordinates from the 0..1 - // passed to it (by makeVortex() in this case) to -1..1, and also reflected the Y - // coordinates. Why the code can't use those from the start I don't - // know... Confusing. Anyway, so here when we store the center of each rectangle - // that the vertices belong to, we need to use the actual coordinates. - mvTileCenters[n] = glm::vec2(2*((x+0.5)/maNumTiles.x) - 1, -2*((y+0.5)/maNumTiles.y) + 1); - - mvTileXIndexes[n] = x; - mvTileYIndexes[n] = y; - mvVertexIndexesInTiles[n] = v; + mvTileInfo[n] = x + (y << 8) + (v << 16); n++; } } } } - glBindBuffer(GL_ARRAY_BUFFER, mnTileCenterBuffer); - CHECK_GL_ERROR(); - glBufferData(GL_ARRAY_BUFFER, mvTileCenters.size()*sizeof(glm::vec2), mvTileCenters.data(), GL_STATIC_DRAW); - CHECK_GL_ERROR(); - - glBindBuffer(GL_ARRAY_BUFFER, mnTileXIndexBuffer); - CHECK_GL_ERROR(); - glBufferData(GL_ARRAY_BUFFER, mvTileXIndexes.size()*sizeof(GLint), mvTileXIndexes.data(), GL_STATIC_DRAW); - CHECK_GL_ERROR(); - - glBindBuffer(GL_ARRAY_BUFFER, mnTileYIndexBuffer); - CHECK_GL_ERROR(); - glBufferData(GL_ARRAY_BUFFER, mvTileYIndexes.size()*sizeof(GLint), mvTileYIndexes.data(), GL_STATIC_DRAW); - CHECK_GL_ERROR(); - - glBindBuffer(GL_ARRAY_BUFFER, mnVertexIndexInTileBuffer); + glBindBuffer(GL_ARRAY_BUFFER, mnTileInfoBuffer); CHECK_GL_ERROR(); - glBufferData(GL_ARRAY_BUFFER, mvVertexIndexesInTiles.size()*sizeof(GLint), mvVertexIndexesInTiles.data(), GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, mvTileInfo.size()*sizeof(GLfloat), mvTileInfo.data(), GL_STATIC_DRAW); CHECK_GL_ERROR(); glBindBuffer(GL_ARRAY_BUFFER, 0); |