Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - glQueryMatrixxOES is broken in QNX 6.4.1: (1 Item)
   
glQueryMatrixxOES is broken in QNX 6.4.1  
While porting GLU nurbs to OpenGL ES 1.0 I've found strange behavior of glQueryMatrixxOES() when quering 
GL_MODELVIEW_MATRIX state. My code:

...

GLint lg2table[32]=
{
   0x00000001,
   0x00000002,
   0x00000004,
   0x00000008,
   0x00000010,
   0x00000020,
   0x00000040,
   0x00000080,

   0x00000100,
   0x00000200,
   0x00000400,
   0x00000800,
   0x00001000,
   0x00002000,
   0x00004000,
   0x00008000,

   0x00010000,
   0x00020000,
   0x00040000,
   0x00080000,
   0x00100000,
   0x00200000,
   0x00400000,
   0x00800000,

   0x01000000,
   0x02000000,
   0x04000000,
   0x08000000,
   0x10000000,
   0x20000000,
   0x40000000,
   0x80000000
};

...

/* Fixed point to float point conversion */
#define FX2F(fx) (GLfloat(fx)/65536.0f)

....

           /* Check if OpenGL ES 1.1 is used, then call glGetFloatv directly */
           #if defined(GL_VERSION_ES_CM_1_1)
              /* Just passthrough the request to OpenGL ES 1.1 */
              glGetFloatv(pname, params);
              return;
           #endif /* GL_VERSION_ES_CM_1_1 */
           /* Check if OpenGL ES 1.0 is used, then try to emulate glGetFloatv */
           #if (defined(GL_OES_VERSION_1_0) || defined(GL_VERSION_ES_CM_1_0)) && !defined(GL_VERSION_ES_CM_1_1)
              /* Check for query_matrix extension, which is very usefull in OpenGL ES 1.0 to obtain */
              /* GLES 1.0 dynamic state                                                             */
              #if defined(GL_OES_query_matrix)
                 {
                    GLfixed mantissa[16];
                    GLint exponent[16];

                    /* Clear the output data, in case if glQueryMatrixxOES() will fail */
                    memset(params, 0x00, 16*sizeof(GLfloat));

                    /* Since OpenGL ES 1.0 has no GL_MATRIX_MODE for glGet() we will try to setup    */
                    /* required matrix and then restore modelview matrix, because it must be default */
                    /* current matrix mode for rendering process.                                    */
                    switch (pname)
                    {
                       case GL_MODELVIEW_MATRIX:
                            glMatrixMode(GL_MODELVIEW);
                            break;
                       case GL_PROJECTION_MATRIX:
                            glMatrixMode(GL_PROJECTION);
                            break;
                    }

                    /* Query current matrix content */
                    if (glQueryMatrixxOES(mantissa, exponent)==0)
                    {
                       for (int it=0; it<16; it++)
                       {
                          params[it]=FX2F(mantissa[it])*lg2table[exponent[it]];
                       }
                    }

                    /* Restore "default" matrix mode */
                    glMatrixMode(GL_MODELVIEW);
                 }
              #else
                 #error "Do not know how to query modelview and projection matrices"
              #endif /* GL_OES_query_matrix */

And the simple OpenGL and OpenGL ES  code, which transforms modelview matrix:

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glTranslatef(0.0, 0.0, -15.0);
   glRotatef(330.0f, 1.0, 0.0, 0.0);
   glRotatef(3.0f, 1.0f, 1.0f, 1.0f);

After this code execution I query the modelview matrix and got:

modelview:
m[0]=0.999084   m[1]=0.000000   m[2]=-0.000000   m[3]=0.000000
m[4]=-0.000000  m[5]=0.880569   m[6]=-0.000000   m[7]=0.000000
m[8]=0.000000   m[9]=0.000000   m[10]=0.880112   m[11]=0.000000
m[12]=0.000000  m[13]=0.000000  m[14]=-15.000000 m[15]=1.000000

You can see, that only diagonal matrix elements are set correctly and m[14] element - translation in Z axis. But when I 
query the same transformed matrix in OpenGL under Windows, not in OpenGL ES, I got:

modelview:
m[0]=0.999086   m[1]=0.011684  ...
View Full Message