1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:17:34 +00:00

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].
This commit is contained in:
Stephan Unverwerth 2021-05-13 19:59:57 +02:00 committed by Andreas Kling
parent a5194274af
commit 0833db0874
4 changed files with 49 additions and 31 deletions

View file

@ -87,6 +87,10 @@ void GLContextWidget::timer_event(Core::TimerEvent&)
* FloatMatrix4x4::rotate(FloatVector3(0, 1, 0), 0.0f)
* FloatMatrix4x4::rotate(FloatVector3(0, 0, 1), angle);
// We need to transpose here because OpenGL expects matrices in column major order
// but our matrix class stores elements in row major order.
matrix = matrix.transpose();
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float*)matrix.elements());