OpenGL API Specifications
Documents and Learning ResourcesSupport Libraries and FrameworksFunction Libraries and GeneratorsThis list contains some basic resources for getting started with, and developing for, OpenGL 3.0 and onwards. Contact your forum moderator if you want to contribute to the list or have any comments.Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 27 March 2010 - 09:30 AM
Posted 28 March 2010 - 01:51 AM
Posted 28 March 2010 - 02:42 AM
Quote:
Original post by tori
Wavarian, are you sure?
src/mesa/main/matrix.c: * -# 4x4 transformation matrices are stored in memory in column major order.
Posted 28 March 2010 - 02:53 AM
Posted 28 March 2010 - 03:39 AM
[ 0 1 2 3 ]or a OpenGL matrix (the transpose of the above one)
[ 4 5 6 7 ]
[ 8 9 10 11 ]
[ 12 13 14 15 ]
[ 0 4 8 12 ]in linear memory (i.e. from lower address to higher address) the layout is
[ 1 5 9 13 ]
[ 2 6 10 14 ]
[ 3 7 11 15 ]
[ 0 1 2 3 ], and in OpenGL a column vector multiplication
[ x y z w ] * [ 4 5 6 7 |
[ 8 9 10 11 ]
[ 12 13 14 15 ]
[ 0 4 8 12 ] [ x [so that the results are identical, aren't they? The quintessence is, that row vectors together with row major order on the one hand, and column vectors together with column major order on the other hand produce the same layout in memory.
[ 1 5 9 13 ] * [ y ]
[ 2 6 10 14 ] [ z ]
[ 3 7 11 15 ] [ w ]
Quote:
Original post by ehsan2004
I have seen an Open Source example that simply works with row major matrices and pre multiplies them and then sends the result to glMultMatrix().
Posted 28 March 2010 - 03:39 AM
mat4(const mat4 &m) {
mat[0] = m[0]; mat[4] = m[4]; mat[8] = m[8]; mat[12] = m[12];
mat[1] = m[1]; mat[5] = m[5]; mat[9] = m[9]; mat[13] = m[13];
mat[2] = m[2]; mat[6] = m[6]; mat[10] = m[10]; mat[14] = m[14];
mat[3] = m[3]; mat[7] = m[7]; mat[11] = m[11]; mat[15] = m[15];
}
mat4 operator*(const mat4 &m) const {
mat4 ret;
ret[0] = mat[0] * m[0] + mat[4] * m[1] + mat[8] * m[2] + mat[12] * m[3];
ret[1] = mat[1] * m[0] + mat[5] * m[1] + mat[9] * m[2] + mat[13] * m[3];
ret[2] = mat[2] * m[0] + mat[6] * m[1] + mat[10] * m[2] + mat[14] * m[3];
ret[3] = mat[3] * m[0] + mat[7] * m[1] + mat[11] * m[2] + mat[15] * m[3];
ret[4] = mat[0] * m[4] + mat[4] * m[5] + mat[8] * m[6] + mat[12] * m[7];
ret[5] = mat[1] * m[4] + mat[5] * m[5] + mat[9] * m[6] + mat[13] * m[7];
ret[6] = mat[2] * m[4] + mat[6] * m[5] + mat[10] * m[6] + mat[14] * m[7];
ret[7] = mat[3] * m[4] + mat[7] * m[5] + mat[11] * m[6] + mat[15] * m[7];
ret[8] = mat[0] * m[8] + mat[4] * m[9] + mat[8] * m[10] + mat[12] * m[11];
ret[9] = mat[1] * m[8] + mat[5] * m[9] + mat[9] * m[10] + mat[13] * m[11];
ret[10] = mat[2] * m[8] + mat[6] * m[9] + mat[10] * m[10] + mat[14] * m[11];
ret[11] = mat[3] * m[8] + mat[7] * m[9] + mat[11] * m[10] + mat[15] * m[11];
ret[12] = mat[0] * m[12] + mat[4] * m[13] + mat[8] * m[14] + mat[12] * m[15];
ret[13] = mat[1] * m[12] + mat[5] * m[13] + mat[9] * m[14] + mat[13] * m[15];
ret[14] = mat[2] * m[12] + mat[6] * m[13] + mat[10] * m[14] + mat[14] * m[15];
ret[15] = mat[3] * m[12] + mat[7] * m[13] + mat[11] * m[14] + mat[15] * m[15];
return ret;
}
void CProjector :: SetupTexMatrix()
{
float offset[16] = { 0.5f, 0, 0, 0,
0, 0.5f, 0, 0,
0, 0, 0, 0,
0.5f,0.5f, 0.0f, 1 };
mat4 m_offset = mat4(offset);
mat4 m_result = m_offset * mat4_projection * mat4_view;
glMatrixMode(GL_TEXTURE);
glLoadMatrixf((GLfloat*) &m_result);
glMatrixMode(GL_MODELVIEW);
}
Posted 28 March 2010 - 03:44 AM
Posted 28 March 2010 - 03:53 AM
Quote:
This means that you need not re-order to use that for either D3D or OpenGL (but you need to do so for e.g. Collada!)
Posted 28 March 2010 - 04:43 AM
Quote:I'm not sure whether that is really a bug. In fact, you have 2 binary criteria (if neglecting esoteric ones), allowing for 4 combinations:
Original post by ehsan2004
Yes, I don't know why Collada has used that ordering. I also transposed the bind shape matrices because Collada stores the transpose of the standard row major ordering! (For example regarding the Collada spec, translation elements are stored in m[3], m[7] and m[11] !
I remember that someone reported the bug to Collada forum, but we still see the same rule in Collada specification.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.