Commit 88566812 authored by Martin Flöser's avatar Martin Flöser
Browse files

Combine built-in vertex with custom fragment shader

ShaderManager supports a new concept to load just a fragment shader from file
and use a built-in shader for the vertex shader. This allows an effect to use
a custom fragment shader.
parent a24bcf73
......@@ -1223,6 +1223,29 @@ void ShaderManager::popShader()
}
}
GLShader *ShaderManager::loadFragmentShader(ShaderType vertex, const QString &fragmentFile)
{
QString vertexShader;
switch (vertex) {
case SimpleShader:
vertexShader = ":/resources/scene-vertex.glsl";
break;
case GenericShader:
vertexShader = ":/resources/scene-generic-vertex.glsl";
break;
case ColorShader:
vertexShader = ":/resources/scene-color-vertex.glsl";
break;
}
GLShader *shader = new GLShader(vertexShader, fragmentFile);
if (shader->isValid()) {
pushShader(shader);
resetShader(vertex);
popShader();
}
return shader;
}
void ShaderManager::initShaders()
{
m_orthoShader = new GLShader(":/resources/scene-vertex.glsl", ":/resources/scene-fragment.glsl");
......
......@@ -388,6 +388,14 @@ class KWIN_EXPORT ShaderManager
**/
void popShader();
/**
* Creates a GLShader with a built-in vertex shader and a custom fragment shader.
* @param vertex The generic vertex shader
* @param fragmentFile The path to the source code of the fragment shader
* @return The created shader
**/
GLShader *loadFragmentShader(ShaderType vertex, const QString &fragmentFile);
/**
* @return a pointer to the ShaderManager instance
**/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment