looking and moving up and down(pitch) using glRotate()
I have a OpenGL program that is like a space simulator. I have the thing correctly turning and flying straight, but things start to get difficult when I try to look up and down. To look up and down, or pitch, I have the program increase pitch by one is down and decrease if up, when the up or down key is pressed. Then, in the draw function, I have the glRotatef function rotate on the x axis up and down according to pitch. Like:
Code:
glRotatef(pitch,1.0f,0,0);
And this works fine if I am facing along the x axis(0(360) or 180 degrees), but say I face 90 degrees on the z axis, the screen rotates around in a circle. I hope you follow me on this. I can't figure out how to fix this, so any suggestions would be great. Thanks!