distortion of sphere while rotating...help

/*
Hi,

I am trying to model a small solar system - sun,
a planet. Sun at the centre, planet goes arnd it.
The problem is that when the planet is closing
towards or moving away from eyes, it appears
distored. sphere appears bulged at poles. Though
when it’s exactly infront of the eyes it’s fine. view is perspective. Here is some code :
*/

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();
glCallList(theSun); //makes a sphere
glTranslatef(0.0,0.0,0.0);
glRotatef(rev_planet,0.0,1.0,0.0);
glTranslatef(-sun_radius*AR,0.0,0.0);
glColor3f(1.0,1.0,1.0);
glCallList(thePlanet);
glPopMatrix();
glutSwapBuffers();
}

void update()
{ //update here
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();

gluPerspective(120.0, (GLfloat)w/(GLfloat)h , 2.0, 3*(sun_radius*4 + planet_radius + 1));

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0,0.0,1.1*(sun_radius*4 + planet_radius),0.0,0.0,0.0,0.0,1.0,0.0);
}

/* completely newbie to graphics as well as
opengl , so (if any then) pls also make comments
on how this code can b optimized
Thanks ,
Amit
*/

>> gluPerspective(120.0, …

As it specifies th fovy, the fovx is likely to be larger (standard monitor is 4:3 aspect ratio).
As the perpective projection is done, the objets appear distorted when approaching the edges of the screen. This effect is stronger with higher fovs, so you will want to stay below 80 degres for fovx.

The only way to completely remove this squashing effect is to use a spherical projection, but it is pretty hard.

To illustrate this see http://wouter.fov120.com/gfxengine/fisheyequake/compare.html especially the part about 150 and 170 degrees fov : look at the green armor. The spherical projection (here called ‘fish eye’) does keep the aspect of objects, whereas the standard planar projection distord them a lot.

Spherical is interesting but also wrong for all views. Displays are flat rectangles and a frustum matching the viewing eyepoint w.r.t. the display will be correct as you originally observed. The distortion of the sphere is perfectly normal, but with a fisheye view it will also be distorted in a different way. The only way to make things look correct is to match the projection geometry with the viewing geometry of the display and for a flat rectangular display that requires a simple frustum, and in your case it’s probably just a matter of reducing the field of view.

Hi,

thanks to both of you for suggestions. i tried
reducing the field and distortion reduced (though
it’s still there). will check about spherical
projection :wink: .

regards,
Amit