glMultMatrixf(GLfloat *m );

I’m trying to transform the modelview matrix.
I had declared pointer matrix[4][4] of GLfloat.
And this is a problem code:

void Transform()
{

glMultMatrix()
glLoadIdentity();

};

Then I recived message:The glMultMatrix request reinterpret_cast.
How I could declare the matrix?

As a single dimensioned array:

GLfloat matrix[16];

I forget what order the rows and columns are stored though.

j

or -

GLfloat matrix[4][4];

glMultMatrix( matrix[0] );

Thank you very much.

Serge K:
Is that really the clean way to go? I mean, does C guarantee, that in two dimensional arrays, the “columns” follow without physical memory seams?

OpenGL uses matrices in column order meaning:

0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15

No, that is [b]wrong[\b].

OpenGL does:

0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15

BTW, why would you Mult the matrix, then call identity?
Oh, and it is better to do glfloat Matrix[16] As a matter of fact some intresting tricks can be done with this, if you use union. (search the message board, there was a good example of this a few weeks (months?) back.

I never used "d arrayer instead I always used 1d and never had any problems.
If get it to load the check out win32asm.virtualave.net under the programming section for some uses for matrices.

The Red Book says that a matrix in OpenGL is represented the way Michael says.

Have a look in the online copy of the book. http://ask.ii.uib.no/ebt-bin/nph-dweb/dy…lhtml;pt=7170#X

Thanks Bob…
Shame on you Elixer!

Oh, you wouldn’t need unions to have these cool effects, by the way. You can also set the byte aligning for the structs. Might be a bit unclean, but should work.

Hmm, well, I know what your looking at, but that is the way math books have it. The way openGL handles it IS the way I said it.

Or if you like:
xX Xy Xz 0
yX yY yZ 0
zX zY zZ 0
lx ly lz 1

And doing a quick seach on google, I found “Matrices can be your Friends. By Steve Baker”
which also says:
Take an opengl matrix:

float m [ 16 ] ;

Consider this as a 4x4 array with it’s elements laid out like this:

0  1  2  3  
4  5  6  7         THE OPENGL WAY
8  9  10 11
12 13 14 15

Yes, I know mathmaticians like to lay the numbers out differently… They prefer
to number them like this:

0  4  8  12  
1  5  9  13         THE MATHEMATICIANS WAY
2  6  10 14
3  7  11 15

So are we all happy now? And shame on you all for doubting me!
(LOL)

I meant the actual order of the elements in memory for opengl. So, physically, the matrix is given to it the way I say.

If it is written in the RedBook, it rules for OpenGL. Did you ever handle the matrices actually in your own program or are you only using the gl functions?

I’m getting totally confused, actually… Shame on you… Anyway, explain it to me more exactly, please.

My (german) math book tells me:

0 1 2 3
4 5 6 7
8 9 19 11
12 13 14 15

My openGL book sais that one should keep in mind that opengl matrices are handled the other way.
Anyway, currently reading Stephen Hawkings short story of time. Seems to be very interresting from what I saw yet…

It interresting me very much if we’re saying the same thing. These are indices of the float[16] array I drew as numbers into the matrix. This is the only logical expression for an opengl matrix, since you can’t tell opengl that you want something to be a row or whatever.

To get clear:
float matrix[16];

A mathematical visual represantation of a matrix, indices are obvious

matrix[0], matrix[4], matrix[8], matrix[12]
matrix[1], matrix[5], matrix[9], matrix[13]
matrix[2], matrix[6], matrix[10], matrix[14]
matrix[3], matrix[7], matrix[11], matrix[15]

So the z axis has the elements 2,6 and 10.

Heh Confusion rules!

ok… snip type :

modelO.gMatrix( rotMatrix2 );
glMultMatrixf( rotMatrix2 );
glTranslatef( -modX, -modY, -modZ );// … and translation.
OBJmodel.Draw(mod2, GLM_SMOOTH|GLM_MATERIAL|GLM_TEXTURE );
glGetFloatv(GL_MODELVIEW_MATRIX, mat1);

now, if we do a dump of mat1, like using:

text.Draw("%.2f %.2f %.2f %.2f",mat1[0],mat1[1],mat1[2],mat1[3]);
text.Draw("%.2f %.2f %.2f %.2f",mat1[4],mat1[5],mat1[6],mat1[7]);
text.Draw("%.2f %.2f %.2f %.2f",mat1[8],mat1[9],mat1[10],mat1[11]);
text.Draw("%.2f %.2f %.2f %.2f",mat1[12],mat1[13],mat1[14],mat1[15]);

would yeild the idenity matrix (say model was at 0,0,0) so the dump would be
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
and if we would translate the model to (-1,2,3) and dump matrix, it would be
1 0 0 0
0 1 0 0
0 0 1 0
-1 2 3 1
and if we truned model around (z axis) the dump would be
1 0 0 0
0 1 0 0
0 0 -1 0
-1 2 3 1

So that means the bottom row tells you where the object is in the world.

(and yes, this is from a program I am doing).

Yeah, so your 2,6,10 is my 8,9,10

Now, lets all have a party.

So you aren’t outputting the matrix correctly. You must output it the way I described.

The identity matrices’ elements don’t get affected by your wrong output (think about it).

It’s wrong what you’re doing. wrong wrong wrong. Ahhhhhhhhh.!:="§%Ä’’"§$*Ü
Okay, getting down again… have fun, I said all.

Actually, the rightmost column is the translation, not the most bottom row.