gl/utils: Fix NDC conversion matrices for column-majorness
authorMatthew Waters <matthew@centricular.com>
Wed, 23 May 2018 16:49:54 +0000 (02:49 +1000)
committerMatthew Waters <matthew@centricular.com>
Wed, 6 Jun 2018 13:36:08 +0000 (23:36 +1000)
commite4bf9ed8f060021151cd57e2b00493ed696cb47b
tree985fdc4a3d418f89c4c49f7213312207d9b429af
parenta7e8f16df3ea662eeea45d5eed53d3d9a42bb164
gl/utils: Fix NDC conversion matrices for column-majorness

The matrices were converting the wrong values with non-diagonal-only matrices.
e.g. a typical yflip matrix in [-1,1]^3 such as
 1  0  0  0
 0 -1  0  0
 0  0  1  0
 0  0  0  1

Would have actually required a matrix like this in [0,1]^3
 1  0  0  0
 0 -1  0  0
 0  0  1  0
 0 -2  0  1

Which is
1. not consistent with our multiplication convention and would require
   transposing matrices or changing our multiplication order (from what is
   generally used on opengl matrix guides/tutorials).
2. Produces incorrect values when input with actual vertices accounting for
   the difference in multiplication order.  e.g. some vertices multiplied by
   the yflip matrix using vertex * yflip(== transpose(yflip) * vertex):

     vertex:       -> result:           expected:
     vec4(1,0,1,1) -> vec4(1,-2,1,1)    vec4(1,1,1,1)
     vec4(1,1,1,1) -> vec4(1,-3,1,1)    vec4(1,0,1,1)

With the updated values, we now get the expected values.

Includes a test for this behaviour and the example above
ext/gl/gstglutils.c
gst-libs/gst/gl/gstglutils.c
tests/check/libs/gstglmatrix.c