- setup_file_texture (mi, which_image);
-}
-
-
-/* Set up and enable lighting */
-static void
-setup_light(void)
-{
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_AUTO_NORMAL);
- glEnable(GL_NORMALIZE);
- glShadeModel(GL_SMOOTH);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
-
- glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
-
-}
-
-
-/* a stipple pattern */
-static GLubyte halftone[] =
-{
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
- 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
-};
-
-/* Set up and enable stippling */
-static void
-setup_stipple(void)
-{
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(halftone);
-}
-
-
-/* Set up and enable face culling so we don't see the inside of the sphere */
-static void
-setup_face(void)
-{
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
-}
-
-
-/* Function for determining points on the surface of the sphere */
-void ParametricSphere(float theta, float rho, float *vector)
-{
- vector[0] = -sin(theta) * sin(rho);
- vector[1] = cos(theta) * sin(rho);
- vector[2] = cos(rho);
- return;
-}
-
-
-/* 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, list, dllist;
- int stacks=STACKS, slices=SLICES;
- float radius=RADIUS;
-
- float drho, dtheta;
- float rho, theta;
- float vector[3];
- float ds, dt, t, s;;
-
- if (wire)
- do_texture = False;
-
- /* turn on various options we like */
- if (do_texture)
- setup_texture(mi);
- if (do_light)
- setup_light();
- if (do_stipple)
- setup_stipple();
-
- setup_face();
-
- dllist=glGenLists(NUM_PLATES);
-
- drho = M_PI / stacks;
- dtheta = 2.0 * M_PI / slices;
- ds = 1.0 / slices;
- dt = 1.0 / stacks;
- t = 0.0 ;
-
-
- /*-
- * Generate a huge sphere with quadrilaterals.
- * Each quad is stored in its own display list; this is so we can
- * move the quads around later (not yet done).
- * Quad vertices are determined using a parametric sphere function.
- * For fun, you could generate practically any parameteric surface and
- * map an image onto it.
- */
-
- list = 0;
- for(i=0; i<stacks; i++) {
- rho = i * drho;
- s = 0.0;
- for(j=0; j<slices+1; j++) {
- theta = j * dtheta;
-
- gp->plates[i].Translation[0] = 0.;
- gp->plates[i].Translation[1] = 0.;
- gp->plates[i].Translation[2] = 0.;
-
- gp->plates[i].RotationRate = 0.;
- gp->plates[i].Angle[0] = 0.;
- gp->plates[i].Angle[1] = 0.;
- gp->plates[i].Angle[2] = 0.;
- gp->plates[i].Angle[3] = 0.;
-
- gp->plates[i].Color[0] = 1.;
- gp->plates[i].Color[1] = 1.;
- gp->plates[i].Color[2] = 1.;
-
- gp->plates[list].platelist = dllist+list;
- glNewList(gp->plates[list].platelist, GL_COMPILE);
- glBegin( wire ? GL_LINE_LOOP : GL_QUADS );
-
- glColor3f(gp->plates[i].Color[0], gp->plates[i].Color[1], gp->plates[i].Color[2]);
-
- glTexCoord2f(s,t);
- ParametricSphere(theta, rho, vector);
- glNormal3fv(vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glTexCoord2f(s,t+dt);
- ParametricSphere(theta, rho+drho, vector);
- glNormal3fv(vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glTexCoord2f(s+ds,t+dt);
- ParametricSphere(theta + dtheta, rho+drho, vector);
- glNormal3fv(vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glTexCoord2f(s+ds, t);
- ParametricSphere(theta + dtheta, rho, vector);
- glNormal3fv(vector);
- glVertex3f( vector[0]*radius, vector[1]*radius, vector[2]*radius );
-
- glEnd();
- s = s + ds;
-
- glEndList();
-
- list++;
- }
- t = t + dt;
- }
-
-
- }
-
-static void
-draw(ModeInfo * mi)
-{
- int i;
- planetstruct *gp = &planets[MI_SCREEN(mi)];
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- for (i=0; i < NUM_PLATES; i++) {
- glPushMatrix();
- /* currently, the angle and translation are 0, but later this can
- * help us move the surface around */
-#if 0
- glRotatef(gp->plates[i].Angle[0],
- gp->plates[i].Angle[1],
- gp->plates[i].Angle[2],
- gp->plates[i].Angle[3]);
- glTranslatef(gp->plates[i].Translation[0],
- gp->plates[i].Translation[1],
- gp->plates[i].Translation[2]);
-#endif
- glCallList(gp->plates[i].platelist);
- glPopMatrix();
-#if 0
- gp->plates[i].Angle[0] += gp->plates[i].RotationRate;
-#endif
- }
-}
-
-
-#define RANDSIGN() ((random() & 1) ? 1 : -1)
-
-static void
-pick_velocity (ModeInfo * mi)
-{
- planetstruct *gp = &planets[MI_SCREEN(mi)];
-
- gp->box_width = 15.0;
- gp->box_height = 15.0;
- gp->box_depth = 60.0;
-
- gp->tx = 0.0;
- gp->ty = 0.0;
- gp->tz = frand(360);
-
- gp->dtx = (frand(0.4) + frand(0.3)) * RANDSIGN();
- gp->dty = (frand(0.4) + frand(0.3)) * RANDSIGN();
- gp->dtz = (frand(5.0) + frand(5.0)); /* the sun sets in the west */
-
- gp->dx = (frand(0.2) + frand(0.2)) * RANDSIGN();
- gp->dy = (frand(0.2) + frand(0.2)) * RANDSIGN();
- gp->dz = (frand(0.2) + frand(0.2)) * RANDSIGN();