Is normal matrix recomputed automatically?

Started by
4 comments, last by V-man 14 years, 1 month ago
If I do a glLoadMatrixf on the modelview matrix in the program, will gl_NormalMatrix be correct in the shader, that is, is it computed automatically any time the projection or modelview are changed? Thanks
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)
Advertisement
Yes.
Sure it does.

But please note that gl_NormalMatrix is supported with compatibility profile only, which should not be a problem for desktop graphics cards since all of them support this profile, and if a graphics card vendor ever tried to stop the support he would lose a massive number of gamers (which are "customers" for them).

This could be a problem for other devices such as mobile platforms, though.

[Edited by - vincoof on March 5, 2010 8:59:30 AM]
I would avoid using gl_NormalMatrix and any other built in stuff if I were you. Even glLoadMatrix should be avoided.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Quote:Original post by V-man
I would avoid using gl_NormalMatrix and any other built in stuff if I were you. Even glLoadMatrix should be avoided.


Hm,what's wrong with glLoadMatrix?I've been using it for pretty long time and don't remember that it caused any problems^^
Because if you are using glLoadMatrix, then that means you are using ftransform() or gl_Projec.... and other junk.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement