I see a few problems with your code. First of all, you don’t seem to have a glutMainLoop() call anywhere. I assume you have it there but just didn’t paste it otherwise I don’t think you would even get a window.
Second… It’s usually best to put the gluPerspective stuff into the resize callback. You also don’t explicitly set the matrix mode, which you probably should do. It would also be a good idea to load the identity matrix into the projection matrix before calling gluProjection. My resize function typically looks something like this.
void Resize(GLuint x, GLuint y)
{
glViewport(0,0,x,y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.333f, 100.0f, 1000000.0f); // what you were using
glMatrixMode(GL_MODELVIEW); // I like to keep the matrix mode here unless changing the projection
}
The other problem I see is that you are doing a push/pop matrix, but never actually modifying it in between. And in your case, you will need to do that becuase glutSolidSphere will place the sphere at 0,0,0, which is in front of your front clipping plane. Inside your push/pop you should be able to do something like so…
glTranslatef(0.0, 0.0, -102.0);
That will push the “world” away from you by 102 units, which should put your sphere into your frustum.
You can also think of this as moving the camera to the position 0,0,102 if you prefer. Generally, though, the “camera” in OpenGL is fixed at 0,0,0. (Not looking at 0,0,0, but positioned there.) The view matrix and the model matrix are all combined into one (the modelview matrix) so if you want to think of it as moving the camera, you do the opposite of what you want the camera to do. For example, you effectively get the same effect by moving the camera by 0,0,102 as you do by moving the world by 0,0,-102.
One method I’ve used to simulate separate camera/world calculations is to do my “camera” translations in the resize function, or when the camera moves. Then for the world positioning, I put stuff inside push/pop calls. Again, when you move the camera, you need to call glLoadIdentity before resetting the camera transformations.
I’m not sure how clear that last description comes across. It’s kind of hard to explain. You should get a copy of the red book for a better explanation of the modelview matrix stuff. You can either buy it or download an old version of it from somewhere. I don’t remember where for sure, but if you do a search on the “Red Book” in this forum, there’s a thread here somewhere with a link to it.