-1.#INDO?
I wrote some code to look at a matrix:
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
float x, y, z;
x = matrix[12]/matrix[15];
y = matrix[13]/matrix[15];
z = matrix[14]/matrix[15];
sprintf(str, "%f, %f, %f", x, y, z);
MessageBox(NULL, str, str, MB_OK);
When I run the previous code after calling gluPerspective it pops up a messagebox that says:
"-1.#IND00, -1.#IND00, -1.#INF00"
What in the world would cause a float to print like that?
Hmmm... actually, I guess the -1.#IND00 is 0/0, and -1.#INF00 is a nonzero number divided by 0....
Okay, this brings up another question. When I look at the GL_MODELVIEW_MATRIX after calling glLoadIdentity, it is like so:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
However, if I look at it after calling gluPerspective(90.0f,1 ,0.1f,100.0f);, I get this:
1 0 0 0
0 1 0 0
0 0 -1.002002 -0.200200
0 0 -1 0
Is this how it should be? Should gluPerspective be putting weird stuff like that in the GL_MODELVIEW_MATRIX?
Mike C.
http://www.coolgroups.com/zoomer
You are correct about the IND/INF values; and gluPerspective is supposed to do something along those lines, yes - it turns the modelview matrix into one that represents the perspective "transformation" specified by the gluPerspective parameters. You would do well to get yourself a good reference on 3D graphics programming and research how the transformation matrices work - there's actually a kinda freaky higher-math idea in there: an N-dimensional matrix is useful just for rotating and shearing N-dimensional spaces (i.e. representing rotational and shear transformations); to do translations, you need to add another dimension, and the translation is basically a shear in that other dimension :) (I *think* I got that right. Don't quote me!)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement