kwin: Simplify ShaderManager::resetShader()
This commit is contained in:
parent
5e97ccf7e0
commit
50e19e2cbc
1 changed files with 41 additions and 46 deletions
|
@ -1283,29 +1283,20 @@ void ShaderManager::initShaders()
|
||||||
void ShaderManager::resetShader(ShaderType type)
|
void ShaderManager::resetShader(ShaderType type)
|
||||||
{
|
{
|
||||||
// resetShader is either called from init or from push, we know that a built-in shader is bound
|
// resetShader is either called from init or from push, we know that a built-in shader is bound
|
||||||
|
const QMatrix4x4 identity;
|
||||||
|
|
||||||
|
QMatrix4x4 projection;
|
||||||
|
QMatrix4x4 modelView;
|
||||||
|
|
||||||
GLShader *shader = getBoundShader();
|
GLShader *shader = getBoundShader();
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SimpleShader: {
|
case SimpleShader:
|
||||||
QMatrix4x4 projection;
|
|
||||||
projection.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535);
|
projection.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535);
|
||||||
shader->setUniform(GLShader::ProjectionMatrix, projection);
|
|
||||||
shader->setUniform(GLShader::Offset, QVector2D(0, 0));
|
|
||||||
shader->setUniform("debug", 0);
|
|
||||||
shader->setUniform("sample", 0);
|
|
||||||
// TODO: has to become textureSize
|
|
||||||
shader->setUniform(GLShader::TextureWidth, 1.0f);
|
|
||||||
shader->setUniform(GLShader::TextureHeight, 1.0f);
|
|
||||||
// TODO: has to become colorManiuplation
|
|
||||||
shader->setUniform(GLShader::Opacity, 1.0f);
|
|
||||||
shader->setUniform(GLShader::Brightness, 1.0f);
|
|
||||||
shader->setUniform(GLShader::Saturation, 1.0f);
|
|
||||||
shader->setUniform(GLShader::AlphaToOne, 0);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case GenericShader: {
|
case GenericShader: {
|
||||||
shader->setUniform("debug", 0);
|
// Set up the projection matrix
|
||||||
shader->setUniform("sample", 0);
|
|
||||||
QMatrix4x4 projection;
|
|
||||||
float fovy = 60.0f;
|
float fovy = 60.0f;
|
||||||
float aspect = 1.0f;
|
float aspect = 1.0f;
|
||||||
float zNear = 0.1f;
|
float zNear = 0.1f;
|
||||||
|
@ -1315,34 +1306,38 @@ void ShaderManager::resetShader(ShaderType type)
|
||||||
float xmin = ymin * aspect;
|
float xmin = ymin * aspect;
|
||||||
float xmax = ymax * aspect;
|
float xmax = ymax * aspect;
|
||||||
projection.frustum(xmin, xmax, ymin, ymax, zNear, zFar);
|
projection.frustum(xmin, xmax, ymin, ymax, zNear, zFar);
|
||||||
shader->setUniform(GLShader::ProjectionMatrix, projection);
|
|
||||||
QMatrix4x4 modelview;
|
// Set up the model-view matrix
|
||||||
float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax;
|
float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax;
|
||||||
modelview.translate(xmin * scaleFactor, ymax * scaleFactor, -1.1);
|
modelView.translate(xmin * scaleFactor, ymax * scaleFactor, -1.1);
|
||||||
modelview.scale((xmax - xmin)*scaleFactor / displayWidth(), -(ymax - ymin)*scaleFactor / displayHeight(), 0.001);
|
modelView.scale((xmax - xmin)*scaleFactor / displayWidth(), -(ymax - ymin)*scaleFactor / displayHeight(), 0.001);
|
||||||
shader->setUniform(GLShader::ModelViewMatrix, modelview);
|
break;
|
||||||
const QMatrix4x4 identity;
|
}
|
||||||
|
|
||||||
|
case ColorShader:
|
||||||
|
projection.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535);
|
||||||
|
shader->setUniform("geometryColor", QVector4D(0, 0, 0, 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//shader->setUniform("debug", 0);
|
||||||
|
shader->setUniform("sample", 0);
|
||||||
|
|
||||||
|
shader->setUniform(GLShader::ProjectionMatrix, projection);
|
||||||
|
shader->setUniform(GLShader::ModelViewMatrix, modelView);
|
||||||
shader->setUniform(GLShader::ScreenTransformation, identity);
|
shader->setUniform(GLShader::ScreenTransformation, identity);
|
||||||
shader->setUniform(GLShader::WindowTransformation, identity);
|
shader->setUniform(GLShader::WindowTransformation, identity);
|
||||||
// TODO: has to become textureSize
|
|
||||||
shader->setUniform(GLShader::TextureWidth, 1.0f);
|
shader->setUniform(GLShader::Offset, QVector2D(0, 0));
|
||||||
shader->setUniform(GLShader::TextureHeight, 1.0f);
|
|
||||||
// TODO: has to become colorManiuplation
|
|
||||||
shader->setUniform(GLShader::Opacity, 1.0f);
|
shader->setUniform(GLShader::Opacity, 1.0f);
|
||||||
shader->setUniform(GLShader::Brightness, 1.0f);
|
shader->setUniform(GLShader::Brightness, 1.0f);
|
||||||
shader->setUniform(GLShader::Saturation, 1.0f);
|
shader->setUniform(GLShader::Saturation, 1.0f);
|
||||||
shader->setUniform(GLShader::AlphaToOne, 0);
|
shader->setUniform(GLShader::AlphaToOne, 0);
|
||||||
break;
|
|
||||||
}
|
// TODO: has to become textureSize
|
||||||
case ColorShader: {
|
shader->setUniform(GLShader::TextureWidth, 1.0f);
|
||||||
QMatrix4x4 projection;
|
shader->setUniform(GLShader::TextureHeight, 1.0f);
|
||||||
projection.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535);
|
|
||||||
shader->setUniform(GLShader::ProjectionMatrix, projection);
|
|
||||||
shader->setUniform(GLShader::Offset, QVector2D(0, 0));
|
|
||||||
shader->setUniform("geometryColor", QVector4D(0, 0, 0, 1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** GLRenderTarget ***/
|
/*** GLRenderTarget ***/
|
||||||
|
|
Loading…
Reference in a new issue