/*
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
*/