- /* disable depth testing for the stars, so they don't obscure the planet */
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_POINT_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glBegin(GL_POINTS);
- for(i = 0 ; i < NUM_STARS ; i++)
- {
-/* size = (drand48()+size_range[0]) * size_range[1]/2.; */
-/* glPointSize(size); */
- x = random()*width;
- y = random()*height;
- glVertex2f(x,y);
- }
- glEnd();
-
- /* return to original PROJECT and MODELVIEW */
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
-
-
- glEndList();
-
-}
-
-/* Initialization function for screen saver */
-static void
-pinit(ModeInfo * mi)
-{
- Bool wire = MI_IS_WIREFRAME(mi);
- planetstruct *gp = &planets[MI_SCREEN(mi)];
- int i, j;
- int stacks=STACKS, slices=SLICES;
- float radius=RADIUS;
-
- float drho, dtheta;
- float rho, theta;
- GLfloat vector[3];
- GLfloat ds, dt, t, s;;
-
- if (wire) {
- glEnable(GL_LINE_SMOOTH);
- do_texture = False;
- }
-
- /* 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;