diff --git a/src/GLWidgetRenderer.cpp b/src/GLWidgetRenderer.cpp index 320026fe..4c0d065b 100644 --- a/src/GLWidgetRenderer.cpp +++ b/src/GLWidgetRenderer.cpp @@ -672,16 +672,21 @@ void GLWidgetRenderer::drawFrame() /* * in Qt4 QMatrix4x4 stores qreal (double), while GLfloat may be float - * Use glm? + * QShaderProgram deal with this case. But compares sizeof(QMatrix4x4) and (GLfloat)*16 + * which seems not correct because QMatrix4x4 has a flag var */ -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + GLfloat *mat = (GLfloat*)d.colorTransform.matrixRef().data(); GLfloat glm[16]; - d.colorTransform.matrixData(glm); - glUniformMatrix4fv(d.u_colorMatrix, 1, GL_TRUE, glm); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if (sizeof(qreal) != sizeof(GLfloat)) { #else - //QMatrix4x4 stores value in Column-major order to match OpenGL. so transpose is not required in glUniformMatrix4fv - glUniformMatrix4fv(d.u_colorMatrix, 1, GL_FALSE, (GLfloat*)d.colorTransform.matrix().constData()); + if (sizeof(float) != sizeof(GLfloat)) { #endif + d.colorTransform.matrixData(glm); + mat = glm; + } + //QMatrix4x4 stores value in Column-major order to match OpenGL. so transpose is not required in glUniformMatrix4fv + glUniformMatrix4fv(d.u_colorMatrix, 1, GL_FALSE, mat); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); diff --git a/src/QtAV/ColorTransform.h b/src/QtAV/ColorTransform.h index 4504a554..41afad61 100644 --- a/src/QtAV/ColorTransform.h +++ b/src/QtAV/ColorTransform.h @@ -48,10 +48,10 @@ public: const QMatrix4x4& matrixRef() const; template void matrixData(T* M) { const QMatrix4x4 &m = matrixRef(); - M[0] = m(0,0), M[1] = m(0,1), M[2] = m(0,2), M[3] = m(0,3), - M[4] = m(1,0), M[5] = m(1,1), M[6] = m(1,2), M[7] = m(1,3), - M[8] = m(2,0), M[9] = m(2,1), M[10] = m(2,2), M[11] = m(2,3), - M[12] = m(3,0), M[13] = m(3,1), M[14] = m(3,2), M[15] = m(3,3); + M[0] = m(0,0), M[4] = m(0,1), M[8] = m(0,2), M[12] = m(0,3), + M[1] = m(1,0), M[5] = m(1,1), M[9] = m(1,2), M[13] = m(1,3), + M[2] = m(2,0), M[6] = m(2,1), M[10] = m(2,2), M[14] = m(2,3), + M[3] = m(3,0), M[7] = m(3,1), M[11] = m(3,2), M[15] = m(3,3); } /*!