[Mesa-dev] [Bug 49703] New: incorrect macros #define M(row, col) m[col*4+row]

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed May 9 12:33:17 PDT 2012


https://bugs.freedesktop.org/show_bug.cgi?id=49703

             Bug #: 49703
           Summary: incorrect macros #define M(row,col)  m[col*4+row]
    Classification: Unclassified
           Product: Mesa
           Version: 8.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: medium
         Component: Mesa core
        AssignedTo: mesa-dev at lists.freedesktop.org
        ReportedBy: chuprin.vladislav at gmail.com


In function _math_matrix_frustum you use incorrect macros in this place

void
_math_matrix_frustum( GLmatrix *mat,
              GLfloat left, GLfloat right,
              GLfloat bottom, GLfloat top,
              GLfloat nearval, GLfloat farval )
{
   GLfloat x, y, a, b, c, d;
   GLfloat m[16];

   x = (2.0F*nearval) / (right-left);
   y = (2.0F*nearval) / (top-bottom);
   a = (right+left) / (right-left);
   b = (top+bottom) / (top-bottom);
   c = -(farval+nearval) / ( farval-nearval);
   d = -(2.0F*farval*nearval) / (farval-nearval);  /* error? */

<b>#define M(row,col)  m[col*4+row]</b>
   M(0,0) = x;     M(0,1) = 0.0F;  M(0,2) = a;      M(0,3) = 0.0F;
   M(1,0) = 0.0F;  M(1,1) = y;     M(1,2) = b;      M(1,3) = 0.0F;
   M(2,0) = 0.0F;  M(2,1) = 0.0F;  M(2,2) = c;      M(2,3) = d;
   M(3,0) = 0.0F;  M(3,1) = 0.0F;  M(3,2) = -1.0F;  M(3,3) = 0.0F;
#undef M

   matrix_multf( mat, m, MAT_FLAG_PERSPECTIVE );
}

If we want use element m[2][3], we must use m[2*4+3] where 2 - row and 3 - col,
but not vice versa.
Correct macros
#define M(row,col)  m[row*4+col]

Sorry for my english.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the mesa-dev mailing list