As I can't reopen #31 , so i open a new issue.
I think there are still something wrong in transform functions.
When compare mesa code and es3 book code,
in "rotate" function, M(row, col) == m[row][col].
but in "frustum" funtions, _M(row, col) == m[col][row]_.
as mesa use 1-D array "M[ ]" stored in column-major, and "#define M(row,col) m[col * 4+row]"; es3 book source code use 2-D array "m[ ][ ]".
Does "rotate" function and "frustum" functions both should be either M(row, col) ==m[row][col] or M(row, col) == m[col][row]???
Or say another way, if we compare the data sequence of 2-D array "m[ ][ ]" which store row by row in the client memory, with the data sequence of 1-D array "M[ ]" in mesa in the client memory, they should be same?? And the data sequences are same when i compare "frustum" & "tranlation" & "scale" functions between mesa code and es3 book code, but "rotate" function doesn't, that's weird.
Mesa v10.6.5 rotate works:
xx = x * x;
yy = y * y;
zz = z * z;
xy = x * y;
yz = y * z;
zx = z * x;
xs = x * s;
ys = y * s;
zs = z * s;
one_c = 1.0F - c;
/* We already hold the identity-matrix so we can skip some statements */
M(0,0) = (one_c * xx) + c;
M(0,1) = (one_c * xy) - zs;
M(0,2) = (one_c * zx) + ys;
/* M(0,3) = 0.0F; */
M(1,0) = (one_c * xy) + zs;
M(1,1) = (one_c * yy) + c;
M(1,2) = (one_c * yz) - xs;
/* M(1,3) = 0.0F; */
M(2,0) = (one_c * zx) - ys;
M(2,1) = (one_c * yz) + xs;
M(2,2) = (one_c * zz) + c;
/* M(2,3) = 0.0F; */
in above codes, _M(row, col) == m[col][row] , as M(0,2) == m[2][0], M(1,2) == m[2][1], M(2,3) == m[3][2], ._ The single data sequence in two matrixes are in the same sequence in the client memory as 2-D array m[ ][ ] stores row by row.
As I can't reopen #31 , so i open a new issue. I think there are still something wrong in transform functions. When compare mesa code and es3 book code, in "rotate" function, M(row, col) == m[row][col]. but in "frustum" funtions, _M(row, col) == m[col][row]_. as mesa use 1-D array "M[ ]" stored in column-major, and "#define M(row,col) m[col * 4+row]"; es3 book source code use 2-D array "m[ ][ ]".
Does "rotate" function and "frustum" functions both should be either M(row, col) ==m[row][col] or M(row, col) == m[col][row]??? Or say another way, if we compare the data sequence of 2-D array "m[ ][ ]" which store row by row in the client memory, with the data sequence of 1-D array "M[ ]" in mesa in the client memory, they should be same?? And the data sequences are same when i compare "frustum" & "tranlation" & "scale" functions between mesa code and es3 book code, but "rotate" function doesn't, that's weird.
Then in above codes, M(row, col) == m[row][col], The single data sequence in two matrixes are not in the same sequence in the client memory.
however, in frustum function,
in above codes, _M(row, col) == m[col][row] , as M(0,2) == m[2][0], M(1,2) == m[2][1], M(2,3) == m[3][2], ._ The single data sequence in two matrixes are in the same sequence in the client memory as 2-D array m[ ][ ] stores row by row.