mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibGL: Transpose matrix in glGetDoublev
and glGetFloatv
We were returning row-major matrices when OpenGL clients are expecting column-major instead.
This commit is contained in:
parent
16255d161e
commit
08826d60ad
1 changed files with 8 additions and 5 deletions
|
@ -1941,12 +1941,15 @@ void SoftwareGLContext::get_floating_point(GLenum pname, T* params)
|
||||||
{
|
{
|
||||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||||
|
|
||||||
// Handle special matrix cases first
|
// Handle matrix retrieval first
|
||||||
auto flatten_and_assign_matrix = [¶ms](const FloatMatrix4x4& matrix) {
|
auto flatten_and_assign_matrix = [¶ms](FloatMatrix4x4 const& matrix) {
|
||||||
auto elements = matrix.elements();
|
auto elements = matrix.elements();
|
||||||
for (size_t i = 0; i < 4; ++i)
|
for (size_t i = 0; i < 4; ++i) {
|
||||||
for (size_t j = 0; j < 4; ++j)
|
for (size_t j = 0; j < 4; ++j) {
|
||||||
params[i * 4 + j] = static_cast<T>(elements[i][j]);
|
// Return transposed matrix since OpenGL defines them as column-major
|
||||||
|
params[i * 4 + j] = static_cast<T>(elements[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_MODELVIEW_MATRIX:
|
case GL_MODELVIEW_MATRIX:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue