소스 검색

LibGL: Transpose matrix in `glGetDoublev` and `glGetFloatv`

We were returning row-major matrices when OpenGL clients are expecting
column-major instead.
Jelle Raaijmakers 3 년 전
부모
커밋
08826d60ad
1개의 변경된 파일8개의 추가작업 그리고 5개의 파일을 삭제
  1. 8 5
      Userland/Libraries/LibGL/SoftwareGLContext.cpp

+ 8 - 5
Userland/Libraries/LibGL/SoftwareGLContext.cpp

@@ -1941,12 +1941,15 @@ void SoftwareGLContext::get_floating_point(GLenum pname, T* params)
 {
     RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
 
-    // Handle special matrix cases first
-    auto flatten_and_assign_matrix = [&params](const FloatMatrix4x4& matrix) {
+    // Handle matrix retrieval first
+    auto flatten_and_assign_matrix = [&params](FloatMatrix4x4 const& matrix) {
         auto elements = matrix.elements();
-        for (size_t i = 0; i < 4; ++i)
-            for (size_t j = 0; j < 4; ++j)
-                params[i * 4 + j] = static_cast<T>(elements[i][j]);
+        for (size_t i = 0; i < 4; ++i) {
+            for (size_t j = 0; j < 4; ++j) {
+                // Return transposed matrix since OpenGL defines them as column-major
+                params[i * 4 + j] = static_cast<T>(elements[j][i]);
+            }
+        }
     };
     switch (pname) {
     case GL_MODELVIEW_MATRIX: