-void
-draw_stars (ModeInfo * mi)
-{
- int width = MI_WIDTH(mi);
- int height = MI_HEIGHT(mi);
-
- planetstruct *gp = &planets[MI_SCREEN(mi)];
-
- /* Sadly, this causes a stall of the graphics pipeline (as would the
- equivalent calls to glGet*.) But there's no way around this, short
- of having each caller set up the specific display matrix we need
- here, which would kind of defeat the purpose of centralizing this
- code in one file.
- */
- glPushAttrib(GL_TRANSFORM_BIT | /* for matrix contents */
- GL_ENABLE_BIT | /* for various glDisable calls */
- GL_CURRENT_BIT | /* for glColor3f() */
- GL_LIST_BIT); /* for glListBase() */
- {
- check_gl_error ("glPushAttrib");
-
- /* disable lighting and texturing when drawing stars!
- (glPopAttrib() restores these.)
- */
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_LIGHTING);
- glDisable(GL_DEPTH_TEST);
-
- /* glPopAttrib() does not restore matrix changes, so we must
- push/pop the matrix stacks to be non-intrusive there.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- {
- check_gl_error ("glPushMatrix");
- glLoadIdentity();
-
- /* Each matrix mode has its own stack, so we need to push/pop
- them separately. */
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- {
- check_gl_error ("glPushMatrix");
- glLoadIdentity();
-
- gluOrtho2D (0, width, 0, height);
- check_gl_error ("gluOrtho2D");
-
- /* Draw the stars */
- glScalef (width, height, 1);
- glCallList(gp->starlist);
- check_gl_error ("drawing stars");
- }
- glPopMatrix();
- }
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
-
- }
- /* clean up after our state changes */
- glPopAttrib();
- check_gl_error ("glPopAttrib");
-}
-
-
-
-/* Set up lighting */
-static void
-init_sun (ModeInfo * mi)
-{
- planetstruct *gp = &planets[MI_SCREEN(mi)];
-
- GLfloat lamb[4] = { 0.1, 0.1, 0.1, 1.0 };
- GLfloat ldif[4] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat spec[4] = { 1.0, 1.0, 1.0, 1.0 };
-
- GLfloat mamb[4] = { 0.5, 0.5, 0.5, 1.0 };
- GLfloat mdif[4] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat mpec[4] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat shiny = .4;
-
- {
- double h = 0.1 + frand(0.8); /* east-west position - screen-side. */
- double v = -0.3 + frand(0.6); /* north-south position */
-
- if (h > 0.3 && h < 0.8) /* avoid having the sun at the camera */
- h += (h > 0.5 ? 0.2 : -0.2);
-
- gp->sunpos[0] = cos(h * M_PI);
- gp->sunpos[1] = sin(h * M_PI);
- gp->sunpos[2] = sin(v * M_PI);
- gp->sunpos[3] = 0.00;
- }
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
-
- glLightfv (GL_LIGHT0, GL_POSITION, gp->sunpos);
- glLightfv (GL_LIGHT0, GL_AMBIENT, lamb);
- glLightfv (GL_LIGHT0, GL_DIFFUSE, ldif);
- glLightfv (GL_LIGHT0, GL_SPECULAR, spec);
-
- glMaterialfv (GL_FRONT, GL_AMBIENT, mamb);
- glMaterialfv (GL_FRONT, GL_DIFFUSE, mdif);
- glMaterialfv (GL_FRONT, GL_SPECULAR, mpec);
- glMaterialf (GL_FRONT, GL_SHININESS, shiny);
-
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glShadeModel(GL_SMOOTH);
-
- check_gl_error("lighting");
-}
-
-
-#define RANDSIGN() ((random() & 1) ? 1 : -1)
-
-void