- glViewport (0, 0, (GLint) width, (GLint) height);
- if (!stars_done)
- {
- int i;
- int nstars = width * height / 320;
- glDeleteLists (sc->star_list, 1);
- sc->star_list = glGenLists (1);
- glNewList (sc->star_list, GL_COMPILE);
- glBegin (GL_POINTS);
- for (i = 0; i < nstars; i++)
- {
- GLfloat c = 0.6 + 0.3 * random() / RAND_MAX;
- glColor3f (c, c, c);
- glVertex3f (2 * width * (0.5 - 1.0 * random() / RAND_MAX),
- 2 * height * (0.5 - 1.0 * random() / RAND_MAX),
- 0.0);
- }
- glEnd ();
- glEndList ();
- stars_done = True;
- }
+ /* Set up matrices for perspective text display
+ */
+ {
+ GLfloat desired_aspect = (GLfloat) 3/4;
+ int w = mi->xgwa.width;
+ int h = mi->xgwa.height;
+
+#ifdef KEEP_ASPECT
+ h = w * desired_aspect;
+#endif
+
+ glMatrixMode (GL_PROJECTION);
+ glViewport (0, 0, w, h);
+
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ gluPerspective (80.0, 1/desired_aspect, 10, 500000);
+ gluLookAt (0.0, 0.0, 4600.0,
+ 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0);
+ glRotatef (-60.0, 1.0, 0.0, 0.0);
+
+ /* The above gives us an arena where the bottom edge of the screen is
+ represented by the line (-2100,-3140,0) - ( 2100,-3140,0). */
+
+ /* Now let's move the origin to the front of the screen. */
+ glTranslatef (0.0, -3140, 0.0);
+
+ /* And then let's scale so that the bottom of the screen is 1.0 wide. */
+ glScalef (4200, 4200, 4200);
+ }
+
+
+ /* Construct stars (number of stars is dependent on size of screen) */
+ {
+ int i;
+ int nstars = width * height / 320;
+ glDeleteLists (sc->star_list, 1);
+ sc->star_list = glGenLists (1);
+ glNewList (sc->star_list, GL_COMPILE);
+ glBegin (GL_POINTS);
+ for (i = 0; i < nstars; i++)
+ {
+ GLfloat c = 0.6 + 0.3 * random() / RAND_MAX;
+ glColor3f (c, c, c);
+ glVertex3f (2 * width * (0.5 - 1.0 * random() / RAND_MAX),
+ 2 * height * (0.5 - 1.0 * random() / RAND_MAX),
+ 0.0);
+ }
+ glEnd ();
+ glEndList ();
+ }
+
+
+ /* Compute the height in pixels of the line at the bottom of the screen. */
+ {
+ GLdouble mm[17], pm[17];
+ GLint vp[5];
+ GLfloat x = 0.5, y1 = 0, z = 0;
+ GLfloat y2 = sc->line_height;
+ GLdouble wx=-1, wy1=-1, wy2=-1, wz=-1;
+
+ glGetDoublev (GL_MODELVIEW_MATRIX, mm);
+ glGetDoublev (GL_PROJECTION_MATRIX, pm);
+ glGetIntegerv (GL_VIEWPORT, vp);
+ gluProject (x, y1, z, mm, pm, vp, &wx, &wy1, &wz);
+ gluProject (x, y2, z, mm, pm, vp, &wx, &wy2, &wz);
+ sc->line_pixel_height = (wy2 - wy1);
+ glLineWidth (1);
+ }
+
+ /* Compute the best looking line thickness for the bottom line.
+ */
+ if (!thick_p)
+ sc->line_thickness = 1.0;
+ else
+ sc->line_thickness = (GLfloat) sc->line_pixel_height / FONT_WEIGHT;
+
+ if (sc->line_thickness < 1.2)
+ sc->line_thickness = 1.0;