summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglshaderprogram.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qglshaderprogram.cpp')
-rw-r--r--src/opengl/qglshaderprogram.cpp76
1 files changed, 9 insertions, 67 deletions
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index 4680131e1d..1062669b52 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -2191,58 +2191,6 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size)
setUniformValue(uniformLocation(name), size);
}
-// We have to repack matrices from qreal to GLfloat.
-#define setUniformMatrix(func,location,value,cols,rows) \
- if (location == -1) \
- return; \
- if (sizeof(qreal) == sizeof(GLfloat)) { \
- func(location, 1, GL_FALSE, \
- reinterpret_cast<const GLfloat *>(value.constData())); \
- } else { \
- GLfloat mat[cols * rows]; \
- const qreal *data = value.constData(); \
- for (int i = 0; i < cols * rows; ++i) \
- mat[i] = data[i]; \
- func(location, 1, GL_FALSE, mat); \
- }
-#if !defined(QT_OPENGL_ES_2)
-#define setUniformGenericMatrix(func,colfunc,location,value,cols,rows) \
- if (location == -1) \
- return; \
- if (sizeof(qreal) == sizeof(GLfloat)) { \
- const GLfloat *data = reinterpret_cast<const GLfloat *> \
- (value.constData()); \
- if (func) \
- func(location, 1, GL_FALSE, data); \
- else \
- colfunc(location, cols, data); \
- } else { \
- GLfloat mat[cols * rows]; \
- const qreal *data = value.constData(); \
- for (int i = 0; i < cols * rows; ++i) \
- mat[i] = data[i]; \
- if (func) \
- func(location, 1, GL_FALSE, mat); \
- else \
- colfunc(location, cols, mat); \
- }
-#else
-#define setUniformGenericMatrix(func,colfunc,location,value,cols,rows) \
- if (location == -1) \
- return; \
- if (sizeof(qreal) == sizeof(GLfloat)) { \
- const GLfloat *data = reinterpret_cast<const GLfloat *> \
- (value.constData()); \
- colfunc(location, cols, data); \
- } else { \
- GLfloat mat[cols * rows]; \
- const qreal *data = value.constData(); \
- for (int i = 0; i < cols * rows; ++i) \
- mat[i] = data[i]; \
- colfunc(location, cols, mat); \
- }
-#endif
-
/*!
Sets the uniform variable at \a location in the current context
to a 2x2 matrix \a value.
@@ -2253,7 +2201,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2);
+ glUniformMatrix2fv(location, 1, GL_FALSE, value.constData());
}
/*!
@@ -2279,8 +2227,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformGenericMatrix
- (glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3);
+ glUniform3fv(location, 2, value.constData());
}
/*!
@@ -2306,8 +2253,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformGenericMatrix
- (glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4);
+ glUniform4fv(location, 2, value.constData());
}
/*!
@@ -2333,8 +2279,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformGenericMatrix
- (glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2);
+ glUniform2fv(location, 3, value.constData());
}
/*!
@@ -2360,7 +2305,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3);
+ glUniformMatrix3fv(location, 1, GL_FALSE, value.constData());
}
/*!
@@ -2386,8 +2331,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformGenericMatrix
- (glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4);
+ glUniform4fv(location, 3, value.constData());
}
/*!
@@ -2413,8 +2357,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformGenericMatrix
- (glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2);
+ glUniform2fv(location, 4, value.constData());
}
/*!
@@ -2440,8 +2383,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformGenericMatrix
- (glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3);
+ glUniform3fv(location, 4, value.constData());
}
/*!
@@ -2467,7 +2409,7 @@ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value)
{
Q_D(QGLShaderProgram);
Q_UNUSED(d);
- setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4);
+ glUniformMatrix4fv(location, 1, GL_FALSE, value.constData());
}
/*!