summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@gmx.de>2021-05-13 19:59:57 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-13 22:24:42 +0200
commit0833db08745f45e89d9ac14901336884b8662255 (patch)
tree09a72e4883d71805c2c79ee142d7e88771a18471 /Userland/Libraries/LibGL
parenta5194274afcd626557f9e0658da2ddc57b22d837 (diff)
downloadserenity-0833db08745f45e89d9ac14901336884b8662255.zip
LibGfx: Make Matrix class consistently row-major
Matrix elements were interpreted in different ways. This makes it definitely row-major, allowing initialization via initializer list in a standard scientific order. Also matrix multiplication now happens in the correct order and accessing elements happens as m_elements[row][column].
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/GLMat.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGL/GLMat.cpp b/Userland/Libraries/LibGL/GLMat.cpp
index a80a54990b..1371f7c49e 100644
--- a/Userland/Libraries/LibGL/GLMat.cpp
+++ b/Userland/Libraries/LibGL/GLMat.cpp
@@ -37,11 +37,14 @@ void glPopMatrix()
void glLoadMatrixf(const GLfloat* matrix)
{
+ // Transpose the matrix here because glLoadMatrix expects elements
+ // in column major order but out Matrix class stores elements in
+ // row major order.
FloatMatrix4x4 mat(
- matrix[0], matrix[1], matrix[2], matrix[3],
- matrix[4], matrix[5], matrix[6], matrix[7],
- matrix[8], matrix[9], matrix[10], matrix[11],
- matrix[12], matrix[13], matrix[14], matrix[15]);
+ matrix[0], matrix[4], matrix[8], matrix[12],
+ matrix[1], matrix[5], matrix[9], matrix[13],
+ matrix[2], matrix[6], matrix[10], matrix[14],
+ matrix[3], matrix[7], matrix[11], matrix[15]);
g_gl_context->gl_load_matrix(mat);
}