Simple vertex shader - weird behavior

Hi,

it’s somewhat my first time dealing with shaders and I’m going through the lighthouse3D GLSL tutorial.
http://www.lighthouse3d.com/opengl/glsl/index.php?flatten


	void main(void)
	{
		vec4 v = vec4(gl_Vertex);		
		v.z = 0.0;
		
		gl_Position = gl_ModelViewProjectionMatrix * v;
	}

In their flatten vertex shader example, my output differs from theirs:
http://img28.imageshack.us/img28/9149/flattenoutput.png

As you can see, my glutTeapot seems to be flattened down in the y axis instead of the z axis as it should.

At first I thought it was the example, but I went further tracking and the following testing makes it even weirder:
http://img341.imageshack.us/img341/1136/flattenoutput1.png
http://img199.imageshack.us/img199/1462/flattenoutput2.png

As you can see, only the glutTeapot doesn’t get it right. In red I have some points loaded from a file, in blue I have a glutSphere to make sure it’s not a glut bug, and finally in green the evil glutTeapot.

So, I’m just curious on what could be causing this behavior?
It’s harder to learn when examples don’t seem to do what they are supposed to :slight_smile:

Thanks in advance!

Ok, after some more testing, I figured that using glRotate here isn’t a good idea.

And I looked at freeglut’s teapot code and they do use glRotate. :slight_smile:

Ahh, since you answered your own question it would seem then that the matrix currently active when you draw the teapot would be critical, This is probably why their code differs from you. They probably have the modelview as the current matrix and you have the projection. Or vice versa.