Read a matrix uniform back from shader.
Might require additions to kwinglutils_func in desktop profile
This commit is contained in:
parent
33dff065fc
commit
1ba818044f
2 changed files with 22 additions and 0 deletions
|
@ -1096,6 +1096,23 @@ void GLShader::bindAttributeLocation(int index, const char* name)
|
|||
// TODO: relink the shader
|
||||
}
|
||||
|
||||
QMatrix4x4 GLShader::getUniformMatrix4x4(const char* name)
|
||||
{
|
||||
int location = uniformLocation(name);
|
||||
if (location >= 0) {
|
||||
GLfloat m[16];
|
||||
glGetUniformfv(mProgram, location, m);
|
||||
QMatrix4x4 matrix(m[0], m[1], m[2], m[3],
|
||||
m[4], m[5], m[6], m[7],
|
||||
m[8], m[9], m[10], m[11],
|
||||
m[12], m[13], m[14], m[15]);
|
||||
matrix.optimize();
|
||||
return matrix;
|
||||
} else {
|
||||
return QMatrix4x4();
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************
|
||||
// ShaderManager
|
||||
//****************************************
|
||||
|
|
|
@ -269,6 +269,11 @@ class KWIN_EXPORT GLShader
|
|||
* @since 4.7
|
||||
*/
|
||||
void bindAttributeLocation(int index, const char* name);
|
||||
/**
|
||||
* @return The value of the uniform as a matrix
|
||||
* @since 4.7
|
||||
**/
|
||||
QMatrix4x4 getUniformMatrix4x4(const char* name);
|
||||
|
||||
void setTextureWidth( float width );
|
||||
void setTextureHeight( float height );
|
||||
|
|
Loading…
Reference in a new issue