vo_opengl: fix row-major vs. column-major confusion

gl_transform_vec() assumed column-major, while everything else seemed to
assumed row-major memory organization for gl_transform.m. Also,
gl_transform_trans() seems to contain additional confusion.

This didn't matter until now, as everything has been orthogonal, this
the swapped matrix entries were always 0.
This commit is contained in:
wm4 2016-03-28 16:16:09 +02:00
parent fb70819048
commit e5b5cc2a2f
2 changed files with 7 additions and 4 deletions

View File

@ -482,8 +482,8 @@ void gl_transform_trans(struct gl_transform t, struct gl_transform *x)
{ {
float x00 = x->m[0][0], x01 = x->m[0][1], x10 = x->m[1][0], x11 = x->m[1][1]; float x00 = x->m[0][0], x01 = x->m[0][1], x10 = x->m[1][0], x11 = x->m[1][1];
x->m[0][0] = t.m[0][0] * x00 + t.m[0][1] * x10; x->m[0][0] = t.m[0][0] * x00 + t.m[0][1] * x10;
x->m[1][0] = t.m[0][0] * x01 + t.m[0][1] * x11; x->m[1][0] = t.m[1][0] * x00 + t.m[1][1] * x10;
x->m[0][1] = t.m[1][0] * x00 + t.m[1][1] * x10; x->m[0][1] = t.m[0][0] * x01 + t.m[0][1] * x11;
x->m[1][1] = t.m[1][0] * x01 + t.m[1][1] * x11; x->m[1][1] = t.m[1][0] * x01 + t.m[1][1] * x11;
gl_transform_vec(t, &x->t[0], &x->t[1]); gl_transform_vec(t, &x->t[0], &x->t[1]);
} }

View File

@ -87,6 +87,9 @@ void fbotex_set_filter(struct fbotex *fbo, GLenum gl_filter);
// A 3x2 matrix, with the translation part separate. // A 3x2 matrix, with the translation part separate.
struct gl_transform { struct gl_transform {
// row-major, e.g. in mathematical notation:
// | m[0][0] m[0][1] |
// | m[1][0] m[1][1] |
float m[2][2]; float m[2][2];
float t[2]; float t[2];
}; };
@ -104,8 +107,8 @@ void gl_transform_ortho(struct gl_transform *t, float x0, float x1,
static inline void gl_transform_vec(struct gl_transform t, float *x, float *y) static inline void gl_transform_vec(struct gl_transform t, float *x, float *y)
{ {
float vx = *x, vy = *y; float vx = *x, vy = *y;
*x = vx * t.m[0][0] + vy * t.m[1][0] + t.t[0]; *x = vx * t.m[0][0] + vy * t.m[0][1] + t.t[0];
*y = vx * t.m[0][1] + vy * t.m[1][1] + t.t[1]; *y = vx * t.m[1][0] + vy * t.m[1][1] + t.t[1];
} }
struct mp_rect_f { struct mp_rect_f {