Starfield Visualisation Problem

Hi,

This may not be appropriate in this forum, but this is a 3D problem and not an OpenGL problem and I think it might be my maths that might be wrong.

I want to create a background of stars, I’ve setup the joystick to rotate the camera/eye around, however the way the stars move seems wrong. The windows exe file can be downloaded here . For those who don’t want to risk running it, the stars move slower in the center and faster at the edges in the direction the camera is moving, and when it is still, the stars seem to be clumped around the center.

The projection matrix is setup like so :-

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-1.0, 1.0, -screen_ratio, screen_ratio, 0.1, 60.0);
  glMatrixMode(GL_MODELVIEW);

The stars are generated using this code, and placed in a display list :-

  glBegin(GL_POINTS);
  for(int i_star = 0; i_star != num_stars; i_star++)
  {
    double theta = getRandDouble() * TWO_PI;
    double phi = (getRandDouble() - 0.5) * PI * getRandDouble(); // Extra randDouble is to make it tend towards the "equator"
    double diminish_rate = getRandDouble();
    GLfloat size = (GLfloat)(0.5 + 1.0*diminish_rate*diminish_rate); // diminish_rate squared to make faint stars more common
    GLdouble y_pos = sin(phi);
    double init_x_pos = cos(phi);
    GLdouble z_pos = init_x_pos * sin(theta);
    GLdouble x_pos = init_x_pos * cos(theta);
    // To put the stars in the distant
    x_pos *= 10.0; y_pos *= 10.0; z_pos *= 10.0;
    glPointSize(size);
    glVertex3d(x_pos, y_pos, z_pos);
  }
  glEnd();

I know “glPointSize(size)” isn’t being stored in the display list, I’m fixing that later. “getRandDouble()” is a macro that returns a float between 0.0 and 1.0.

When I call the list I simply load the identity matrix, rotate using variables manipulated by the joystick, then call the list.

In other words, an imaginary sphere is made around the camera/eye and points are places randomly along the sphere. The effect I’m looking for is that the user can’t tell how close they are. When I have foreground objects later, I will disable the depth buffer when the stars are being drawn so they seem to be well beyond the far limit of the fustrum.

I’ve ran this through my mind and have tried to find out the reason for this but I can’t. It will probably be something stupid in the end. Any help or advise is appreciated.

Thanks,
Steve

Sorry for bugging the forum, I’ve solved the problem. I replaced glFrustum with gluPerspective. I had a feeling I didn’t need to post but I was getting desperate.