- /* turn on various options we like */
- if (do_texture)
- setup_texture(mi);
- if (do_light)
- setup_light();
-
- setup_face();
-
- if (do_stars) {
- glEnable(GL_POINT_SMOOTH);
- generate_stars(MI_WIDTH(mi), MI_HEIGHT(mi));
- }
-
-
- /*-
- * Generate a sphere with quadrilaterals.
- * Quad vertices are determined using a parametric sphere function.
- * For fun, you could generate practically any parameteric surface and
- * map an image onto it.
- */
-
- drho = M_PI / stacks;
- dtheta = 2.0 * M_PI / slices;
- ds = 1.0 / slices;
- dt = 1.0 / stacks;
-
-
- gp->platelist=glGenLists(1);
- glNewList(gp->platelist, GL_COMPILE);
-
- glColor3f(1,1,1);
- glBegin( wire ? GL_LINE_LOOP : GL_QUADS );
-
- t = 0.0;
- for(i=0; i<stacks; i++) {
- rho = i * drho;
- s = 0.0;
- for(j=0; j<slices; j++) {
- theta = j * dtheta;
-
-
- glTexCoord2f(s,t);
- ParametricSphere(theta, rho, vector);
- normalize(vector);
- glNormal3fv(vector);
- ParametricSphere(theta, rho, vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glTexCoord2f(s,t+dt);
- ParametricSphere(theta, rho+drho, vector);
- normalize(vector);
- glNormal3fv(vector);
- ParametricSphere(theta, rho+drho, vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glTexCoord2f(s+ds,t+dt);
- ParametricSphere(theta + dtheta, rho+drho, vector);
- normalize(vector);
- glNormal3fv(vector);
- ParametricSphere(theta + dtheta, rho+drho, vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glTexCoord2f(s+ds, t);
- ParametricSphere(theta + dtheta, rho, vector);
- normalize(vector);
- glNormal3fv(vector);
- ParametricSphere(theta + dtheta, rho, vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- s = s + ds;
-
- }
- t = t + dt;
- }
- glEnd();
- glEndList();
-
-
- }
-
-static void
-draw_sphere(ModeInfo * mi)
-{
- planetstruct *gp = &planets[MI_SCREEN(mi)];
-
- glEnable(GL_DEPTH_TEST);
-
- /* turn on the various attributes for making the sphere look nice */
- if (do_texture)
- glEnable(GL_TEXTURE_2D);
-
- if (do_light)
- {
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
- }
-
- glCallList(gp->platelist);
-
+ gp->starlist = glGenLists(1);
+ glNewList(gp->starlist, GL_COMPILE);
+ for (j = 1; j <= steps; j++)
+ {
+ glPointSize(inc * j * scale);
+ glBegin (GL_POINTS);
+ for (i = 0; i < nstars / steps; i++)
+ {
+ GLfloat d = 0.1;
+ GLfloat r = 0.15 + frand(0.3);
+ GLfloat g = r + frand(d) - d;
+ GLfloat b = r + frand(d) - d;
+
+ GLfloat x = frand(1)-0.5;
+ GLfloat y = frand(1)-0.5;
+ GLfloat z = ((random() & 1)
+ ? frand(1)-0.5
+ : (BELLRAND(1)-0.5)/12); /* milky way */
+ d = sqrt (x*x + y*y + z*z);
+ x /= d;
+ y /= d;
+ z /= d;
+ glColor3f (r, g, b);
+ glVertex3f (x, y, z);
+ gp->starcount++;
+ }
+ glEnd ();
+ }
+ glEndList ();
+
+ check_gl_error("stars initialization");