Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: column major matrix multiplication

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2008
    Posts
    5

    column major matrix multiplication

    Hello,
    I've created a matrix class for use in OpenGL,
    the matrix class uses two-dimensional float array,
    how should I do multiplication of matrices correctly ?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,190

    Re: column major matrix multiplication

    Quote Originally Posted by khdani
    Hello,
    I've created a matrix class for use in OpenGL,
    the matrix class uses two-dimensional float array,
    how should I do multiplication of matrices correctly ?
    A tip: OpenGL is column-major operator-on-the-left (e.g. P*V*M * v1 = v2)
    This is the same as row-major operator-on-the-right (e.g. v1 * M*V*P = v2).

    Flipping both results in a net-zero change in the math. You get exactly the same values in exactly the same memory locations.

    So since C/C++ is row-major, do the second one. More here. With this you can spoon your row-major operator-on-the-right matrices directly to OpenGL (which expects column-major operator-on-the-left matrices) via glLoadMatrixd, glMatrixLoadf, glUniformMatrix4fv, or whatever... No need to waste time on useless transpose operations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •