home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include "stdio.h"
- #include "gl.h"
- #include "demograph.h"
- #include "kurtfont.h"
-
- #define MARGIN 3
- #define FPSSTRING "Frames per second: "
- #define FPSCHARS 5 /* number of characters for float */
- #define FPSLEN (strlen(FPSSTRING) + MARGIN * 2 + FPSCHARS)
-
- #define DATASTR "Data: "
- #define DATASTRLEN 6
-
- extern WINREC winrec;
- extern CATEGORY *curcategory;
-
- FONTREC title;
- FONTREC fps;
- FONTREC curdate;
-
-
- void writetitle(str)
- char *str;
- {
- static char datastr[MAXDATA+DATASTRLEN+1];
-
- /* clear the old title string */
- setcolor(0xbb,0xbb,0xbb);
- sboxfi ((int)(title.xoffset),(int)(title.yoffset),
- (int)(title.xoffset + title.xscale * strlen(str) * 6.0),
- (int)(title.yoffset + title.yscale * 9.0));
-
- /* draw the new title string */
- setcolor(0,0,0);
- linewidth(title.lwid);
- sprintf(datastr,"%s%s",DATASTR,str);
- stroke(title.xoffset,title.yoffset,0.0,title.xscale, title.yscale, 1.0,
- datastr);
- linewidth(1);
- }
-
-
- void writefps(frames_per_sec)
- float frames_per_sec;
- {
- static char fpsstr[32];
-
- sprintf(fpsstr,"%1.3f",frames_per_sec);
-
- frontbuffer(TRUE);
-
- /* clear old frames_per_second string */
- setcolor(0xbb,0xbb,0xbb);
- sboxfi ((int)(fps.xoffset),(int)(fps.yoffset),
- (int)(fps.xoffset + fps.xscale * strlen(fpsstr) * 6.0),
- (int)(fps.yoffset + fps.yscale * 9.0));
-
- /* draw the new text */
- setcolor(0,0,0);
- linewidth(fps.lwid);
- stroke(fps.xoffset,fps.yoffset,0.0,fps.xscale, fps.yscale, 1.0, fpsstr);
- linewidth(1);
- frontbuffer(FALSE);
- }
-
-
- void writesliderdate(sliderdate, x)
- char *sliderdate;
- float x;
- {
- linewidth(curdate.lwid);
-
- setcolor(0,0,0);
- stroke(x+curdate.xoffset, curdate.yoffset, 0.0, curdate.xscale,
- curdate.yscale, 1.0, sliderdate);
- linewidth(1);
- }
-
-
- void init_text()
- {
- register float sizex;
- register int nchars;
-
- /* get font info for button */
- curdate.xscale = winrec.scale;
- curdate.yscale = winrec.scale;
- curdate.xoffset = -(DATECHARS * 6.0)/2.0 * curdate.xscale;
- curdate.yoffset =
- ((winrec.sliderminy+winrec.slidermaxy)/2.0)-(3.5 * winrec.scale);
-
- /* get font info for title */
- nchars = DATASTRLEN + MAXTITLE + (MARGIN * 2);
- if (FPSLEN > nchars && winrec.fps) {
- nchars = FPSLEN;
- }
- sizex = (winrec.statmaxx - winrec.statminx + winrec.scale) / 2.0;
- title.xscale = sizex / (nchars * 6.0);
- title.yscale = winrec.scale;
- title.yoffset = (winrec.statmaxy+winrec.statminy)/2.0 - title.yscale * 3.5;
- if (!winrec.fps) { /* center justified */
- title.xoffset = (sizex - winrec.scale) -
- ((((strlen(curcategory->title) + DATASTRLEN)*6.0)/ 2.0) * title.xscale);
- } else { /* left justified */
- title.xoffset = MARGIN * 6.0 * title.xscale;
-
- /* set up frames_per_second text structure */
- fps.xscale = title.xscale;
- fps.yscale = title.yscale;
- fps.yoffset = title.yoffset;
- fps.xoffset = (winrec.statmaxx - sizex - winrec.scale)
- + MARGIN * 6.0 * fps.xscale;
- fps.lwid = (int)(winrec.scale);
- /* draw permanent text now and update leater */
- linewidth(fps.lwid);
- setcolor(0,0,0);
- stroke(fps.xoffset,fps.yoffset,0.0,
- fps.xscale,fps.yscale,1.0,FPSSTRING);
- fps.xoffset += (float)(strlen(FPSSTRING)) * 6.0 * fps.xscale;
- linewidth(1);
- }
- curdate.lwid = title.lwid = (int)(winrec.scale);
- }
-
-
- stroke(tx,ty,tz,sx,sy,sz,str)
- float tx,ty,tz,sx,sy,sz;
- char *str;
- {
- register int i, mode;
-
- pushmatrix();
- translate(tx,ty,tz);
- scale(sx,sy,sz);
- for (; *str; str++) {
- if (chrtbl[*str][0][0]) {
- for (i=0; mode = chrtbl[*str][i][0]; i++) {
- switch (mode) {
- case 1:
- translate(
- (float)chrtbl[*str][i][1],
- (float)chrtbl[*str][i][2],
- 0.0);
- break;
- case 2:
- bgnline();
- v2i(&chrtbl[*str][i][1]);
- break;
- case 3:
- v2i(&chrtbl[*str][i][1]);
- break;
- case 4:
- v2i(&chrtbl[*str][i][1]);
- endline();
- break;
- }
- }
- }
- }
- popmatrix();
- }
-