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 3 of 3

Thread: Matrix composition confussion GLES2 example

  1. #1
    Newbie Newbie
    Join Date
    May 2014
    Posts
    2

    Matrix composition confussion GLES2 example

    Hello

    I'm trying to understand some GLES2 basic examples. In particular, I'm following this example here:
    https://github.com/robclark/kmscube/...ster/kmscube.c

    The problem is it seems to be using some twisted matrix maths.
    If we take a look at this call:
    Code :
    esMatrixMultiply(&modelviewprojection, &modelview, &projection);
    we can see it's composing the modelviewprojection matrix like this: modelview . projection
    It's ok, let's suppose it's because modelview and projection are column-major matrices, so we are obtainig the correct matrix but in column-major format. But then, why do we see this on the GLSL vertex shader?
    Code :
    "    gl_Position = modelviewprojectionMatrix * in_position;\n"
    This makes no sense at all: if we have a column-major modelviewprojection matrix, we should use it like this:
    Code :
    "    gl_Position = in_position * modelviewprojectionMatrix;\n"
    where in_position is a row-vector instead of the usual column vector.

    My other question is: why does esRotate() produce row-major matrices while esFrustrum() produces column-major matrices? Makes no sense. One or the other, but why is it different in each one?

    thanks

  2. #2
    Newbie Newbie
    Join Date
    May 2014
    Posts
    1
    You're mixing up column-major/row-major matrices with column/row vectors.

  3. #3
    Newbie Newbie
    Join Date
    May 2014
    Posts
    2
    Ok, let's see:
    -In OpenGL, and in GLSL in particular, I think vectors are column vectors. So if matrices are NOT transposed, like in this case, matrices pre-multiply to them: MATRIX * vertex;
    -If the modelviewprojection matrix is NOT transposed, then it should be composed like this:

    Code :
    esMatrixMultiply(&modelviewprojection, &projection, &modelview);

    because projection is done AFTER modelview transformations, and NOT like this:

    Code :
    esMatrixMultiply(&modelviewprojection, &modelview, &projection);


    So, what am I missing here, please?

Posting Permissions

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