From 753df55973b14a3ab9929122efadce417986878f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 11 Dec 2010 11:10:33 +0100 Subject: [PATCH] Set Color as a uniform --- lib/kwinglutils.cpp | 9 +++++++++ lib/kwinglutils.h | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index 50593af815..eca93a789e 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -1040,6 +1040,15 @@ bool GLShader::setUniform(const char* name, const QMatrix4x4& value) return (location >= 0); } +bool GLShader::setUniform(const char* name, const QColor& color) +{ + const int location = uniformLocation(name); + if (location >= 0) { + glUniform4f(location, color.redF(), color.greenF(), color.blueF(), color.alphaF()); + } + return (location >= 0); +} + int GLShader::attributeLocation(const char* name) { int location = glGetAttribLocation(mProgram, name); diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index cc928848d0..8ff045b71d 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -258,6 +258,7 @@ class KWIN_EXPORT GLShader bool setUniform(const char* name, const QVector3D& value); bool setUniform(const char* name, const QVector4D& value); bool setUniform(const char* name, const QMatrix4x4& value); + bool setUniform(const char* name, const QColor& color); int attributeLocation(const char* name); bool setAttribute(const char* name, float value); /**