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

Thread: OpenGL Row-Major mode?

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    2

    OpenGL Row-Major mode?

    Yes, I do understand that OpenGL uses column-major matricies for their transformations. (Ok, yes, I know, not 'technically' Column major, due to storage and everything... but I do believe you understand what I am getting at).

    I heard a rumor, at my college, that OpenGL has an option to toggle using a "Row-Major" mode for transformations, instead of Column Major.

    I have searched the internet to no avail, as of yet, to see if it is true. I personally prefer using Row-Major transformations, simply because it makes more logical sense to me to execute the transformations in an in-order fashion (as opposed to what I've used in OpenGL so far, which involves putting my first transformation at the very bottom, just before beginning a primitive, and then putting the last transformation that affects them at the very top of the transformation list... which feels very reverse-order).

    Thankfully, my current project handles it's matricies outside of OpenGL, only to use something like glMultMatrix to import them when things need to be drawn. They are row matricies, as is. So, if there is no "row-major" mode, would I merely be able to call glMultMatrix on the transpose of my row-major matrix, and have it work as expected?

    Sorry, you guys probably get this question a lot.

    -Serge

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml

    void glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);

    P.S. or just do
    gl_Position = gl_Vertex * mvp;
    instead of
    gl_Position = mvp * gl_Vertex;

    (and have your uploaded data be in row-major, without transpose=true)
    Last edited by Ilian Dinev; 06-06-2012 at 01:12 AM.

  3. #3
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    The difference in "row major" and "column major" is only in what order the numbers are stored in memory. It as no effects on matrix mathematics. That means that the only situation where you have to care about the order is when you transfer data between different systems, or if you design your own matrix manipulation functions.

    Also, consider not using the deprecated fixed function pipeline and use shaders instead. glMultMatrix() is a deprecated function.

    Maybe have a look at glm, a highly optimized matrix library, specially adapted for use with OpenGL.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,180
    Alternatively, and if you need to stick with the old calls, use glMultTransposeMatrix: http://www.opengl.org/sdk/docs/man/x...poseMatrix.xml

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,186
    Another approach which avoids the transpose (if you do your own matrix math):

    * Re: Order of initializing matrices

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    2
    Can you point me in the direction of "Shaders"?
    I've worked in HLSL once, in the past; However, I have never had the chance to learn OpenGL shaders.

    Any good guides?

  7. #7
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    Quote Originally Posted by IAmSerge View Post
    Can you point me in the direction of "Shaders"?
    I've worked in HLSL once, in the past; However, I have never had the chance to learn OpenGL shaders.

    Any good guides?
    I would recommend: http://www.arcsynthesis.org/gltut/Ba...he%20Data.html
    Maybe you want to read that tutorial from the beginning.

Tags for this Thread

Posting Permissions

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