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: Problem with OpenGL Superbible example (solved)

  1. #1
    Intern Contributor
    Join Date
    Jun 2011
    Posts
    89

    Problem with OpenGL Superbible example (solved)

    This book uses a library named GLTools in all of its example code.

    The book emphasizes that matrices are stored in column major(check the GLTools source code), but in its code examples, when calling glUniformMatrix4fv,
    for example
    Code :
    glUniformMatrix4fv(locMVP, 1, GL_FALSE,
    lightTransformPipeline.GetModelViewProjectionMatrix());
    the third parameter is always false, which means the matrices it provides are in row major, which is contrary to what they said about their matrices, but it works.

    Why?

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    433

    Re: Problem with OpenGL Superbible example

    If you read http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml it states:
    If transpose is GL_FALSE, each matrix is assumed to be supplied in column major order. If transpose is GL_TRUE, each matrix is assumed to be supplied in row major order.
    See http://www.opengl.org/resources/faq/...formations.htm which also points you to the 2.1 spec, where the relevant section is:
    Quote Originally Posted by OpenGL_2.1_Specification
    LoadMatrix takes a pointer to a 4 4 matrix stored in column-major order as 16
    consecutive floating-point values, i.e. as
    Code :
    [ a1 a5 a9  a13 ]
    [ a2 a6 a10 a14 ]
    [ a3 a7 a11 a15 ]
    [ a4 a8 a12 a16 ]
    This differs from the standard row-major C ordering for matrix elements. If the
    standard ordering is used, all of the subsequent transformation equations are transposed,
    and the columns representing vectors become rows.)
    I don't think that later versions of the OpenGL spec state this as clearly, since the documentation for LoadMatrix has gone, but this bit of advice hasn't been put anywhere else.

  3. #3
    Intern Contributor
    Join Date
    Jun 2011
    Posts
    89

    Re: Problem with OpenGL Superbible example

    Thank you very much.

    I should have checked the specification first.

Posting Permissions

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