diff --git a/effects/lookingglass/CMakeLists.txt b/effects/lookingglass/CMakeLists.txt index 45a4d19f86..26d72ddef4 100644 --- a/effects/lookingglass/CMakeLists.txt +++ b/effects/lookingglass/CMakeLists.txt @@ -15,8 +15,11 @@ install( FILES # Data files install( FILES - lookingglass/data/lookingglass.frag - DESTINATION ${DATA_INSTALL_DIR}/kwin ) + lookingglass/data/1.10/lookingglass.frag + DESTINATION ${DATA_INSTALL_DIR}/kwin/shaders/1.10 ) +install( FILES + lookingglass/data/1.40/lookingglass.frag + DESTINATION ${DATA_INSTALL_DIR}/kwin/shaders/1.40 ) ####################################### # Config diff --git a/effects/lookingglass/data/lookingglass.frag b/effects/lookingglass/data/1.10/lookingglass.frag similarity index 100% rename from effects/lookingglass/data/lookingglass.frag rename to effects/lookingglass/data/1.10/lookingglass.frag diff --git a/effects/lookingglass/data/1.40/lookingglass.frag b/effects/lookingglass/data/1.40/lookingglass.frag new file mode 100644 index 0000000000..239afc2699 --- /dev/null +++ b/effects/lookingglass/data/1.40/lookingglass.frag @@ -0,0 +1,28 @@ +#version 140 +uniform sampler2D sampler; +uniform vec2 u_cursor; +uniform float u_zoom; +uniform float u_radius; +uniform vec2 u_textureSize; + +in vec2 varyingTexCoords; + +out vec4 fragColor; + +#define PI 3.14159 + +void main() +{ + vec2 d = u_cursor - varyingTexCoords; + float dist = sqrt(d.x*d.x + d.y*d.y); + vec2 texcoord = varyingTexCoords; + if (dist < u_radius) { + float disp = sin(dist / u_radius * PI) * (u_zoom - 1.0) * 20.0; + texcoord += d / dist * disp; + } + + texcoord = texcoord/u_textureSize; + texcoord.t = 1.0 - texcoord.t; + fragColor = texture(sampler, texcoord); +} + diff --git a/effects/lookingglass/lookingglass.cpp b/effects/lookingglass/lookingglass.cpp index c5e77e6cfd..aaf1dc7c48 100644 --- a/effects/lookingglass/lookingglass.cpp +++ b/effects/lookingglass/lookingglass.cpp @@ -116,7 +116,12 @@ bool LookingGlassEffect::loadData() return false; } - const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/lookingglass.frag"); + QString shadersDir = "kwin/shaders/1.10/"; +#ifndef KWIN_HAVE_OPENGLES + if (GLPlatform::instance()->glslVersion() >= kVersionNumber(1, 40)) + shadersDir = "kwin/shaders/1.40/"; +#endif + const QString fragmentshader = KGlobal::dirs()->findResource("data", shadersDir + "lookingglass.frag"); m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::SimpleShader, fragmentshader); if (m_shader->isValid()) { ShaderBinder binder(m_shader);