+ glPushMatrix();
+ glRotatef (gp->z * 360, 0, 0, 1);
+ glCallList (gp->platelist);
+ mi->polygon_count += resolution*resolution;
+ glPopMatrix();
+
+ /* Originally we just used GL_LIGHT0 to produce the day/night sides of
+ the planet, but that always looked crappy, even with a vast number of
+ polygons, because the day/night terminator didn't exactly line up with
+ the polygon edges.
+
+ So instead, draw the full "day" sphere; clear the depth buffer; draw
+ a rotated/tilted half-sphere into the depth buffer only; then draw
+ the "night" sphere. That lets us divide the sphere into the two maps,
+ and the dividing line can be at any angle, regardless of polygon layout.
+
+ The half-sphere is scaled slightly larger to avoid polygon fighting,
+ since those triangles won't exactly line up because of the rotation.
+
+ The downside of this is that the day/night terminator is 100% sharp.
+ It would be nice if it was a little blurry.
+ */
+
+ if (wire)
+ {
+ glPushMatrix();
+ glRotatef (gp->tilt, 1, 0, 0);
+ glColor3f(0, 0, 0);
+ glLineWidth(4);
+ glCallList (gp->shadowlist);
+ glLineWidth(1);
+ mi->polygon_count += resolution*(resolution/2);
+ glPopMatrix();
+ }
+ else if (do_texture && gp->tex2)
+ {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glDisable(GL_TEXTURE_2D);
+ glColorMask (0, 0, 0, 0);
+ glPushMatrix();
+ glRotatef (gp->tilt, 1, 0, 0);
+ glScalef (1.01, 1.01, 1.01);
+ glCallList (gp->shadowlist);
+ mi->polygon_count += resolution*(resolution/2);
+ glPopMatrix();
+ glColorMask (1, 1, 1, 1);
+ glEnable(GL_TEXTURE_2D);
+
+ glBindTexture (GL_TEXTURE_2D, gp->tex2);
+ glPushMatrix();
+ glRotatef (gp->z * 360, 0, 0, 1);
+ glCallList (gp->platelist);
+ mi->polygon_count += resolution*resolution;
+ glPopMatrix();
+ }
+
+ if (gp->draw_axis)
+ {
+ glPushMatrix();
+ glRotatef (gp->z * 360, 0.0, 0.0, 1.0);
+ glScalef (1.02, 1.02, 1.02);
+ glDisable (GL_TEXTURE_2D);
+ glDisable (GL_LIGHTING);
+ glDisable (GL_LINE_SMOOTH);
+ glColor3f (0.1, 0.3, 0.1);
+ glCallList (gp->latlonglist);
+ mi->polygon_count += 24*24;
+ glPopMatrix();
+ if (gp->draw_axis) gp->draw_axis--;
+ }
+ glPopMatrix();