RE: [info-performer] pfGetViewMat and pfGetProjMat

Date view Thread view Subject view Author view

From: Don Burns (don++at++andesengineering.com)
Date: 01/13/2005 09:42:11


Hm... well, not really. Yes, OpenGL is column major literarily (that
means, it says so in the books)... but practically it is not. What I mean
here is that a transpose is really not necessary. The matrix passed to
glMultMatrix(), or glLoadMatrix() is, by all by all intents and purposes,
a row-major matrix.

Prove this to yourself. Write a little OpenGL program that translates an
object along the X axis by 'X':

// This will work:
    GLfloat mat[][4] = {
        { 1.0, 0.0, 0.0, 0.0},
        { 0.0, 1.0, 0.0, 0.0},
        { 0.0, 0.0, 1.0, 0.0},
        { X, 0.0, 0.0, 1.0}
    };

    glPushMatrix();
    glMultMatrixf( &mat[0][0] );
    glutSolidTeapot( 1.0 );
    glPopMatrix();

    a += 0.01;

/// But this....

    GLfloat mat[][4] = {
        { 1.0, 0.0, 0.0, X},
        { 0.0, 1.0, 0.0, 0.0},
        { 0.0, 0.0, 1.0, 0.0},
        { 0.0, 0.0, 0.0, 1.0}
    };

... will have most amusing results.

Cheers,

-don

On Thu, 13 Jan 2005, Dick Rous wrote:

> There IS a difference.
> Matrices in Performer are represented in row-major form,
> while OpenGL uses a column-major ordering.
> So, to go from Performer to OpenGL (or vice versa), you have to transpose
> the pfMatrix.
>
> Eg, a translation matrix in Performer looks like:
>
> 1 0 0 0
> 0 1 0 0
> 0 0 1 0
> x y z 1
>
> While in OpenGL this is represented as:
>
> 1 0 0 x
> 0 1 0 y
> 0 0 1 z
> 0 0 0 1
>
> Hope this helps,
>
> Dick.
>
>
> > -----Original Message-----
> > From: owner-info-performer++at++performer.engr.sgi.com
> > [mailto:owner-info-performer++at++performer.engr.sgi.com] On
> > Behalf Of faculaganymede
> > Sent: Wednesday, 12 January, 2005 17:33
> > To: SGI Performer MailList
> > Subject: [info-performer] pfGetViewMat and pfGetProjMat
> >
> > Hi All,
> >
> > Inside the channel draw call back function, I am making some
> > calls to read the current projection and viewing matrices. I
> > get different results from
> > glGetFloatv() and the pfGet$_Mat() functions; the values of
> > the returned matrices are different. Does anyone know why? I
> > thought these two functions are equilvalent!?
> >
> > Code fragment:
> > ...
> > pfDraw();
> >
> > // GL
> > GLfloat projMatD[16];
> > GLfloat modelViewMatD[16];
> > glGetFloatv(GL_PROJECTION_MATRIX, projMatD);
> > glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatD);
> >
> > // PF
> > pfMatrix ViewMat;
> > pfMatrix ProjMat;
> > pfGetViewMat(ViewMat);
> > pfGetProjMat(ProjMat);
> > ...
> >
> > =====
> > Thanks,
> > faculaganymede
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > All your favorites on one personal page - Try My Yahoo!
> > http://my.yahoo.com
> >
> > --------------------------------------------------------------
> > ---------
> > List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> > Open Development Project: http://oss.sgi.com/projects/performer/
> > Submissions: info-performer++at++sgi.com
> > Admin. requests: info-performer-request++at++sgi.com
> > --------------------------------------------------------------
> > ---------
> >
>
> -----------------------------------------------------------------------
> List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
> -----------------------------------------------------------------------
>
>


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Jan 13 2005 - 09:42:21 PST