GLSL 1.40 shader for CoverSwitch Reflection

Shader moved to 1.10 subdirectory and a new version for 1.40 added.
At the same time call to glPolygonMode removed as it caused errors with
core context (and seems to not be needed).

REVIEW: 110572
This commit is contained in:
Martin Gräßlin 2013-05-21 10:33:02 +02:00
parent c1486596fb
commit c00d468f0f
4 changed files with 24 additions and 6 deletions

View file

@ -14,8 +14,11 @@ install( FILES
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
install( FILES
coverswitch/coverswitch-reflection.glsl
DESTINATION ${DATA_INSTALL_DIR}/kwin )
coverswitch/shaders/1.10/coverswitch-reflection.glsl
DESTINATION ${DATA_INSTALL_DIR}/kwin/shaders/1.10 )
install( FILES
coverswitch/shaders/1.40/coverswitch-reflection.glsl
DESTINATION ${DATA_INSTALL_DIR}/kwin/shaders/1.40 )
#######################################

View file

@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDE/KIcon>
#include <kwinglutils.h>
#include <kwinglplatform.h>
#include <math.h>
@ -66,7 +67,12 @@ CoverSwitchEffect::CoverSwitchEffect()
captionFont.setBold(true);
captionFont.setPointSize(captionFont.pointSize() * 2);
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/coverswitch-reflection.glsl");
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 + "coverswitch-reflection.glsl");
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int)));
@ -264,9 +270,6 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d
paintScene(frontWindow, leftWindows, rightWindows, true);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifndef KWIN_HAVE_OPENGLES
glPolygonMode(GL_FRONT, GL_FILL);
#endif
// we can use a huge scale factor (needed to calculate the rearground vertices)
// as we restrict with a PaintClipper painting on the current screen
float reflectionScaleFactor = 100000 * tan(60.0 * M_PI / 360.0f) / area.width();

View file

@ -0,0 +1,12 @@
#version 140
uniform vec4 u_frontColor;
uniform vec4 u_backColor;
in vec2 varyingTexCoords;
out vec4 fragColor;
void main()
{
fragColor = u_frontColor*(1.0-varyingTexCoords.s) + u_backColor*varyingTexCoords.s;
}