home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / demos / gpc / init_bench.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-07  |  33.8 KB  |  1,110 lines

  1. /* $XConsortium: init_bench.c,v 5.4 91/05/07 12:02:43 rws Exp $ */
  2. /***********************************************************
  3. Copyright(c) 1989,1990, 1991 by Sun Microsystems, Inc. and the X Consortium at M.I.T.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its
  8. documentation for any purpose and without fee is hereby granted,
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in
  11. supporting documentation, and that the names of Sun Microsystems,
  12. the X Consortium, and MIT not be used in advertising or publicity
  13. pertaining to distribution of the software without specific, written
  14. prior permission.
  15.  
  16. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  18. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  19. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. SOFTWARE.
  23.  
  24. ******************************************************************/
  25.  
  26. /*--------------------------------------------------------------------*\
  27. |
  28. |  Copyright (C) 1989,1990, 1991, National Computer Graphics Association
  29. |
  30. |  Permission is granted to any individual or institution to use, copy, or
  31. |  redistribute this software so long as it is not sold for profit, provided
  32. |  this copyright notice is retained.
  33. |
  34. |                         Developed for the
  35. |                National Computer Graphics Association
  36. |                         2722 Merrilee Drive
  37. |                         Fairfax, VA  22031
  38. |                           (703) 698-9600
  39. |
  40. |                                by
  41. |                 SimGraphics Engineering Corporation
  42. |                    1137 Huntington Drive  Unit A
  43. |                      South Pasadena, CA  91030
  44. |                           (213) 255-0900
  45. |---------------------------------------------------------------------
  46. |
  47. | Author        :    SimGraphics Engineering Corportation
  48. |
  49. | File          :    init_bench.c
  50. | Date          :    Fri Feb  9 10:46:55 PST 1990
  51. | Project       :    PLB
  52. | Description   :    
  53. | Status        :    Version 1.0
  54. |
  55. | Revisions     :    
  56. |
  57. |       2/90            MFC Tektronix, Inc.: PEX-SI API implementation.
  58. |
  59. |       5/90            MFC Tektronix, Inc.: PEX-SI API Binding change.
  60. |
  61. \*--------------------------------------------------------------------*/
  62.  
  63. /*--------------------------------------------------------------------*\
  64. |    Table of Contents
  65. |    void init_bench( *Bench_setup, *Wk_info)
  66. |        :    Initialize the graphics subsystem for testing
  67. |    void init_border_str(int, int)
  68. |        :    Defines the border structure
  69. |
  70. \*--------------------------------------------------------------------*/
  71.  
  72. /*--------------------------------------------------------------------*\
  73. |    Include files
  74. \*--------------------------------------------------------------------*/
  75. #include <stdio.h>
  76. #include "biftypes.h"
  77. #include "globals.h"
  78. #include "ph_map.h"
  79. #include "bifparse.h"
  80. #include "stopwatch.h"
  81. #ifdef USING_PHIGS
  82. #include <X11/Xlib.h>
  83. #include <X11/Xutil.h>
  84. #include <X11/Xresource.h>
  85. #include <X11/Xatom.h>
  86. #include <ctype.h>
  87. #include "brfexption.h"
  88. #include "brftypes.h"
  89. #include "brfexmacro.h"
  90. #endif /* USING_PHIGS */
  91.  
  92. /* ---------------------------------------------------------------------*\
  93. |Local #define                                                           |
  94. \*--------------------------------------------------------------------- */
  95. #ifndef FALSE
  96. #define FALSE 0
  97. #endif
  98. #ifndef TRUE
  99. #define TRUE (!FALSE)
  100. #endif
  101.  
  102. /* Constants to add specific system info to Report Header at run time */
  103. #define NCOUNT 40
  104. #define NSYSLN 3
  105. #define NHRDLN 4
  106. #define NOSVLN 7
  107. #define NWNVLN 8
  108. #define NWNSLN 9
  109. #define NTMALN 10
  110.  
  111. extern char *BRF_appendToColon();
  112.  
  113. /*--------------------------------------------------------------------*\
  114. |    Local MACROS
  115. \*--------------------------------------------------------------------*/
  116.  
  117. #ifdef USING_PHIGS
  118. #define    CONNECT_TO_DISPLAY(name)\
  119.     if(!(dpy=XOpenDisplay(name))){\
  120.         fprintf(stderr,"Cannot open display\n");\
  121.         exit(-1);\
  122.     }
  123.  
  124. #define CHECK_PHIGS_OPEN \
  125.         { Psys_st sys_st; \
  126.             pinq_sys_st(&sys_st); \
  127.         if (sys_st != PSYS_ST_PHOP) { \
  128.             fprintf(stderr,"PHIGS not open, Aborting.\n"); \
  129.             exit(-1); \
  130.         } \
  131.     }
  132.  
  133. #define CHECK_WS_OPEN \
  134.         { Pws_st ws_st; \
  135.             pinq_ws_st(&ws_st); \
  136.         if (ws_st != PWS_ST_WSOP) { \
  137.             fprintf(stderr,"PHIGS WORKSTATION not open, Aborting.\n"); \
  138.             pclose_phigs(); \
  139.             exit(-1); \
  140.         } \
  141.     }
  142.  
  143. #define MXPIX (Pfloat)(0xffff)
  144. #define CALC_COLOR_PIXEL(cm,r,g,b) \
  145.         ((cm).base_pixel + \
  146.          ((unsigned long)(0.5 + (r) * (cm).red_max) * (cm).red_mult) + \
  147.          ((unsigned long)(0.5 + (g) * (cm).green_max) * (cm).green_mult) + \
  148.          ((unsigned long)(0.5 + (b) * (cm).blue_max) * (cm).blue_mult))
  149. #endif /* USING_PHIGS */
  150.  
  151. /*--------------------------------------------------------------------*\
  152. |    Local global variables
  153. \*--------------------------------------------------------------------*/
  154.  
  155. extern char *brf_sysinfo[];
  156.  
  157. #ifdef USING_PHIGS
  158. static Pfloat ur,ug,ub;
  159. static Display *dpy;
  160. static Window win;
  161. static XSetWindowAttributes xswa;
  162. static Visual visual;
  163. static XStandardColormap ci;
  164. static XrmValue val;
  165. static XSizeHints size_hints;
  166. static XrmDatabase dis_db;
  167. static char tmpln[80];
  168. static char *str_type;
  169. #endif /* USING_PHIGS */
  170.  
  171. /* ---------------------------------------------------------------------*\
  172. | Contents:                                                              |
  173. \*--------------------------------------------------------------------- */
  174. #ifdef FULL_FUNCT_PROTO_TYPE
  175.  
  176. void init_bench( Bench_setup*,Wk_invo*);
  177.  
  178. #else /* ifdef FULL_FUNCT_PROTO_TYPE */
  179.  
  180. void init_bench();
  181.  
  182. #endif /* ifdef FULL_FUNCT_PROTO_TYPE */
  183.  
  184.  
  185. /* ---------------------------------------------------------------------*\
  186. | BEGIN PROCEDURE CODE                                                   |
  187. \*--------------------------------------------------------------------- */
  188.  
  189. #ifdef USING_PHIGS
  190. #define LIST_SIZE 30
  191. typedef struct _err_def {
  192.     int type;
  193.     char *type_string;
  194. } err_def;
  195.  
  196. #define NUM_MARKER_TYPES 5
  197. static err_def marker_types[NUM_MARKER_TYPES] = {
  198.     { 1, "MARKER_TYPE MK_POINT not supported.\n" },
  199.     { 2, "MARKER_TYPE MK_PLUS not supported.\n" },
  200.     { 3, "MARKER_TYPE MK_ASTER not supported.\n" },
  201.     { 4, "MARKER_TYPE MK_CIRCLE not supported.\n" },
  202.     { 5, "MARKER_TYPE MK_X not supported.\n" }
  203. };
  204.  
  205. #define NUM_LINE_TYPES 4
  206. static err_def line_types[NUM_LINE_TYPES] = {
  207.     { 1, "LINE_TYPE LINE_SOLID not supported.\n" },
  208.     { 2, "LINE_TYPE LINE_DASH not supported.\n" },
  209.     { 3, "LINE_TYPE LINE_DOTTED not supported.\n" },
  210.     { 4, "LINE_TYPE LINE_DASHDOT not supported.\n" }
  211. };
  212.  
  213. #define NUM_LINE_SHADES 2
  214. static err_def line_shades[NUM_LINE_SHADES] = {
  215.     { 1, "LINE_SHADING LINE_SHADE_FLAT not supported.\n" },
  216.     { 2, "LINE_SHADING LINE_SHADE_COLOR not supported.\n" }
  217. };
  218.  
  219. #define NUM_INTERIOR_TYPES 4
  220. static err_def interior_types[NUM_INTERIOR_TYPES] = {
  221.     { 0, "INTERIOR_STYLE HOLLOW not supported.\n" },
  222.     { 1, "INTERIOR_STYLE SOLID not supported.\n" },
  223.     { 2, "INTERIOR_STYLE PATTERN not supported.\n" },
  224.     { 4, "INTERIOR_STYLE EMPTY not supported.\n" }
  225. };
  226.  
  227. #define NUM_INTERIOR_SHADES 4
  228. static err_def interior_shade_types[NUM_INTERIOR_SHADES] = {
  229.     { 1, "INTERIOR_SHADING SHADE_FLAT not supported.\n" },
  230.     { 2, "INTERIOR_SHADING SHADE_GOURAUD not supported.\n" },
  231.     { 3, "INTERIOR_SHADING SHADE_DOT not supported.\n" },
  232.     { 4, "INTERIOR_SHADING SHADE_PHONG not supported.\n" }
  233. };
  234.  
  235. #define NUM_INTERIOR_REFLECS 4
  236. static err_def interior_reflecs[NUM_INTERIOR_REFLECS] = {
  237.     { 1, "INTERIOR_LIGHTING LIGHT_NONE not supported.\n" },
  238.     { 2, "INTERIOR_LIGHTING LIGHT_AMBIENT not supported.\n" },
  239.     { 3, "INTERIOR_LIGHTING LIGHT_DIFFUSE not supported.\n" },
  240.     { 4, "INTERIOR_LIGHTING LIGHT_SPECULAR not supported.\n" }
  241. };
  242.  
  243. #define NUM_EDGE_TYPES 4
  244. static err_def edge_types[NUM_EDGE_TYPES] = {
  245.     { 1, "EDGE_TYPE EDGE_SOLID not supported.\n" },
  246.     { 2, "EDGE_TYPE EDGE_DASH not supported.\n" },
  247.     { 3, "EDGE_TYPE EDGE_DOTTED not supported.\n" },
  248.     { 4, "EDGE_TYPE EDGE_DASHDOT not supported.\n" }
  249. };
  250.  
  251. #define NUM_HLHSR_MODES 5
  252. static char *hlhsr_modes[NUM_HLHSR_MODES] = {
  253.     "NONE", "ZBUFF", "PAINTERS", "SCANLINE", "LINE"
  254. };
  255.  
  256. Pconnid_x_drawable conn;
  257. extern int BRF_do_optiontest();
  258. extern int BRF_realrange();
  259. extern int BRF_intrange();
  260. extern int BRF_truecolor();
  261. extern int BRF_pseudocolor();
  262. extern BRF_exception brf_exception[];
  263. #endif /* USING_PHIGS */
  264.  
  265. static int upcase(source,dest)
  266. char *source;
  267. char *dest;
  268. {
  269.     for (;*source != 0; source++,dest++) {
  270.     *dest = islower(*source) ? toupper(*source) : *source;
  271.     }
  272.     *dest = 0;
  273. }
  274.  
  275. /*----------------------------------------------------------------------*\
  276. | Procedure     :    void init_bench( *Bench_setup, *Wk_info)
  277. |--------------------------------------------------------------------------|
  278. | Description   :    Initialize the graphics subsystem for testing
  279. |--------------------------------------------------------------------------|
  280. | Return        :    
  281. \*----------------------------------------------------------------------*/
  282. void init_bench( benchsetup,wkinfo)
  283. Bench_setup *benchsetup;
  284. Wk_info *wkinfo;
  285.  
  286. {
  287. /*----------------------------------------------------------------------*\
  288. |     Open the phigs and the workstation
  289. \*----------------------------------------------------------------------*/
  290. #ifdef USING_PHIGS
  291.     static char err_file[] = "BIFPEX.err";
  292.     static char *Single_Buffer[] = {
  293.         (char *)PHIGS_X_BUF_MODE, (char *)PHIGS_BUF_SINGLE,
  294.         (char *)0
  295.         };
  296.     static char *Double_Buffer[] = {
  297.         (char *)PHIGS_X_BUF_MODE, (char *)PHIGS_BUF_DOUBLE,
  298.         (char *)0
  299.         };
  300.     Pconnid conn_id;
  301.     Pint gpc_ws;
  302.     Pfloat xdist, ydist;
  303.     Pint err_ind;
  304.     Pupd_st gpc_upd;
  305.     Plimit3 gpc_win;
  306.     Plimit3 gpc_dum,gpc_cur_vp;
  307.     char user_display[256];
  308.     int depth;
  309.     char *resources;
  310.  
  311.     user_display[0] = '\0'; /* Set default display */
  312.  
  313.     /* Check for display on the command line */
  314.     (void *)strcpy(tmpln, Prog_name);
  315.     (void *)strcat(tmpln, ".display");
  316.     if (XrmGetResource(gpc_res_db, tmpln, (char *)NULL, &str_type, &val))
  317.         (void *)strcpy(user_display, val.addr);
  318.  
  319.     CONNECT_TO_DISPLAY(user_display);
  320.  
  321.     /* Now get the resources from the server */
  322.     resources = XResourceManagerString(dpy);
  323.     if (!resources)
  324.         resources = "";
  325.     dis_db = XrmGetStringDatabase(resources);
  326.     XrmMergeDatabases(gpc_res_db, &dis_db);
  327.  
  328.     /* Fill out vendor specific entries in the report file */
  329.     SetVendorEntries();
  330.  
  331.     /* Get the appropriate visual and colormap */
  332.     if (!CreateColormap(dpy, &visual, &depth, &ci)) {
  333.         fprintf(stderr,"Could not find appropriate color map\n");
  334.         exit(-1);
  335.     }
  336.  
  337.     CreateTheWindow(wkinfo, depth);
  338.  
  339.     gpc_ws = phigs_ws_type_x_drawable;
  340.     conn.display = dpy;
  341.     conn.drawable_id = win;
  342.  
  343.     /* Open PHIGS */
  344.     popen_phigs((char *)err_file,PDEF_MEM_SIZE);
  345.  
  346.     CHECK_PHIGS_OPEN;
  347.  
  348.     /* Set up for Single/Double buffer, PEX supports PSEUDO-COLOR and
  349.        TRUE_COLOR so no explicit setting is required */
  350.  
  351.     /* First check if the user wants a different buffer mode */
  352.     (void *)strcpy(tmpln, Prog_name);
  353.     (void *)strcat(tmpln, ".bufferMode");
  354.     if (XrmGetResource(dis_db, tmpln, (char *)NULL, &str_type, &val)) {
  355.         upcase(val.addr,tmpln);
  356.         if (!strcmp(tmpln,"SINGLE")) {
  357.         if (wkinfo->buffer_mode != SINGLE_BUFFER)
  358.             PLB_EXCEPTION(BIF_EX_BUFFMODE);
  359.         wkinfo->buffer_mode = SINGLE_BUFFER;
  360.         }
  361.         else if (!strcmp(tmpln,"DOUBLE")) {
  362.         if (wkinfo->buffer_mode != DOUBLE_BUFFER)
  363.             PLB_EXCEPTION(BIF_EX_BUFFMODE);
  364.         wkinfo->buffer_mode = DOUBLE_BUFFER;
  365.         }
  366.     }
  367.  
  368.     switch(wkinfo->buffer_mode)
  369.     {
  370.       case DOUBLE_BUFFER:
  371.         gpc_ws = phigs_ws_type_create(gpc_ws, (char *)PHIGS_X_BUF_MODE,
  372.                       (char *)PHIGS_BUF_DOUBLE, (char *)0);
  373.         break;
  374.       case SINGLE_BUFFER:
  375.         gpc_ws = phigs_ws_type_create(gpc_ws, (char *)PHIGS_X_BUF_MODE, 
  376.                       (char *)PHIGS_BUF_SINGLE, (char *)0);
  377.         break;
  378.     }
  379.  
  380.     popen_ws((Pint)benchsetup->workid,(Pconnid)&conn,gpc_ws);
  381.  
  382.     CHECK_WS_OPEN;
  383.  
  384.     pset_disp_upd_st((Pint)benchsetup->workid,PDEFER_WAIT,PMODE_NIVE);
  385.  
  386.     /* Now get the connected Workstation type */
  387.     pinq_ws_conn_type((Pint)benchsetup->workid, 0, &err_ind,
  388.               &conn_id, &gpc_ws);
  389.  
  390.     /* Get the Viewport Size from the PHIGS API */
  391.     pinq_ws_tran3((Pint)benchsetup->workid,&err_ind,&gpc_upd,
  392.               &gpc_dum,&gpc_dum,&gpc_dum,&gpc_cur_vp);
  393.  
  394.     if (!err_ind) {
  395.         xdist = gpc_cur_vp.x_max - gpc_cur_vp.x_min;
  396.         ydist = gpc_cur_vp.y_max - gpc_cur_vp.y_min;
  397.     }
  398.     else {
  399.         xdist = wkinfo->x;
  400.         ydist = wkinfo->y;
  401.     }
  402.     /* Fill out the size field in the report file */
  403.     sprintf(tmpln,"%ld x %ld",(int)xdist,(int)ydist);
  404.     BRF_appendToColon(brf_sysinfo[NWNSLN],tmpln);
  405.  
  406.     /* Check for window size being the same as the test file requested */
  407.     if ((xdist != wkinfo->x) || (ydist != wkinfo->y)) 
  408.         PLB_EXCEPTION(BIF_EX_WINSIZE);
  409.  
  410.     /* Set the aspect ratio and workstation window transform */
  411.     wkinfo->aspect_ratio = xdist/ydist;
  412.     gpc_win.x_min = gpc_win.y_min = gpc_win.z_min = 0.0;
  413.     gpc_win.x_max = gpc_win.y_max = gpc_win.z_max = 1.0;
  414.     if (wkinfo->aspect_ratio != 1.0) {
  415.         if (wkinfo->aspect_ratio > 1.0)
  416.         gpc_win.y_max /= wkinfo->aspect_ratio;
  417.         else
  418.         gpc_win.x_max *= wkinfo->aspect_ratio;
  419.     }
  420.  
  421.     pset_ws_win3((Pint)benchsetup->workid, &gpc_win);
  422.  
  423. #endif /* USING_PHIGS */
  424.  
  425. /*----------------------------------------------------------------------*\
  426. |     Initialize the Bif traverser to execute mode.
  427. \*----------------------------------------------------------------------*/
  428.     do_endstructure(traverser_state,NULL);
  429.  
  430. /*----------------------------------------------------------------------*\
  431. |     Get workstation information: color table depth, screen aspect ratio
  432. \*----------------------------------------------------------------------*/
  433. #ifdef USING_PHIGS
  434.     GetWorkstationInfo(gpc_ws, (Pint)benchsetup->workid, wkinfo);
  435. #else
  436.     wkinfo->cmap_size = 256;
  437.     wkinfo->aspect_ratio = 1.0;
  438. #endif /* USING_PHIGS */
  439.  
  440. /*----------------------------------------------------------------------*\
  441. |     Set up the base_state structure.  This structure contains all the 
  442. |    attributes which are allowed outside of bif structures but not 
  443. |    allowed outside of phigs structures (which is ALL of them)
  444. \*----------------------------------------------------------------------*/
  445.     init_base_state(benchsetup->base_state_stid,
  446.             benchsetup->base_state_vid);
  447.  
  448.  
  449. /*----------------------------------------------------------------------*\
  450. |     Set up the border structure.  The border is always displayed
  451. \*----------------------------------------------------------------------*/
  452.  
  453.     /*
  454.     init_border_struct(benchsetup->border_stid,
  455.                benchsetup->border_vid);
  456.         */
  457.     /*
  458.      * We do not have a border structure, the window title supports
  459.      * the name 
  460.      */
  461.     benchsetup->border_stid = 0; /* Don't display border structure */
  462.  
  463.     /* Set the phigs open state to open */
  464.     wkinfo->phigs_open = 1;
  465.  
  466. /*----------------------------------------------------------------------*\
  467. |       Set Color Maps to Default Values.
  468. \*----------------------------------------------------------------------*/
  469.  
  470.  
  471. #ifdef USING_PHIGS
  472.     SetDefaultColors(benchsetup->workid);
  473. #endif
  474.     
  475.  
  476. } /* End procedure init_bench */
  477.  
  478. #ifdef USING_PHIGS
  479. #define REDS_256 5
  480. #define GREENS_256 9
  481. #define BLUES_256 5
  482.  
  483. extern XStandardColormap *XmuStandardColormap();
  484. extern Screen *_XScreenOfWindow ();
  485. /*
  486.  *                     WARNING
  487.  * 
  488.  * This is a ICCCM routine.  It will reference the new fields
  489.  * in the XStandardColormap structure.
  490.  */
  491.  
  492. Status ICCM_XGetStandardColormap (display, w, cmap, property)
  493.     Display *display;
  494.     Window w;
  495.     XStandardColormap *cmap;
  496.     Atom property;        /* XA_RGB_BEST_MAP, etc. */
  497. {
  498.     Status stat;            /* return value */
  499.     XStandardColormap *stdcmaps;    /* will get malloced value */
  500.     int nstdcmaps;            /* count of above */
  501.  
  502.     stat = XGetRGBColormaps (display, w, &stdcmaps, &nstdcmaps, property);
  503.     if (stat) {
  504.     XStandardColormap *use;
  505.  
  506.     if (nstdcmaps > 1) {
  507.         VisualID vid;
  508.         Screen *sp = _XScreenOfWindow (display, w);
  509.         int i;
  510.  
  511.         if (!sp) {
  512.         if (stdcmaps) XFree ((char *) stdcmaps);
  513.         return FALSE;
  514.         }
  515.         vid = sp->root_visual->visualid;
  516.  
  517.         for (i = 0; i < nstdcmaps; i++) {
  518.         if (stdcmaps[i].visualid == vid) break;
  519.         }
  520.  
  521.         if (i == nstdcmaps) {    /* not found */
  522.         XFree ((char *) stdcmaps);
  523.         return FALSE;
  524.         }
  525.         use = &stdcmaps[i];
  526.     } else {
  527.         use = stdcmaps;
  528.     }
  529.         
  530.     cmap->colormap     = use->colormap;
  531.     cmap->red_max     = use->red_max;
  532.     cmap->red_mult     = use->red_mult;
  533.     cmap->green_max     = use->green_max;
  534.     cmap->green_mult = use->green_mult;
  535.     cmap->blue_max     = use->blue_max;
  536.     cmap->blue_mult     = use->blue_mult;
  537.     cmap->base_pixel = use->base_pixel;
  538.     cmap->visualid   = use->visualid;
  539.     cmap->killid     = use->killid;
  540.  
  541.     XFree ((char *) stdcmaps);    /* don't need alloced memory */
  542.     }
  543.     return stat;
  544. }
  545.  
  546. CreateColormap(display, vs, depth, cm)
  547. Display *display;
  548. Visual *vs;
  549. int *depth;
  550. XStandardColormap *cm;
  551. {
  552.     XVisualInfo        *available_visuals, *the_best, template;
  553.     XStandardColormap     std;
  554.     Visual        *root_visual;
  555.     int             nvisuals, i, found;
  556.     
  557.     template.screen = DefaultScreen(display); 
  558.     available_visuals = XGetVisualInfo(display, VisualScreenMask,
  559.                        &template, &nvisuals);
  560.  
  561.     /* 
  562.      * Get a standard colormap, the visual, depth and property
  563.      * Precedence is defined as follows:
  564.      *    Use existing RGB_DEFAULT_MAP or RGB_BEST_MAP
  565.      *    Use root-visual and create RGB_BEST_MAP
  566.      *    Fail
  567.      *
  568.      */
  569.  
  570.     if ((ICCM_XGetStandardColormap(display,RootWindow(display,
  571.                               DefaultScreen(display)),
  572.                   &std,XA_RGB_BEST_MAP) && std.colormap) ||
  573.     (ICCM_XGetStandardColormap(display,RootWindow(display,
  574.                               DefaultScreen(display)),
  575.                   &std,XA_RGB_DEFAULT_MAP) && std.colormap)) {
  576.     /* The standard colormap visual might not be the Default */
  577.     *cm = std;
  578.     for (i = 0; i < nvisuals; i++) {
  579.         if (available_visuals[i].visualid == std.visualid) {
  580.         the_best = &available_visuals[i];
  581.         break;
  582.         }
  583.     }
  584.     }
  585.     else {
  586.     found = FALSE;
  587.     /* Try to use the root-visual */
  588.     root_visual = DefaultVisual(display, template.screen);
  589.     for (i = 0; i < nvisuals; i++) {
  590.         if (available_visuals[i].visualid == root_visual->visualid) {
  591.         the_best = &available_visuals[i];
  592.         break;
  593.         }
  594.     }
  595.     switch (the_best->visual->class) {
  596.       case StaticGray:
  597.       case GrayScale:
  598.         break; /* Can't use */
  599.       case DirectColor:
  600.       case PseudoColor:
  601.         /* Try the default map */
  602.         *cm = *(XmuStandardColormap(display,DefaultScreen(display),
  603.                     the_best->visual->visualid,
  604.                     the_best->depth,XA_RGB_DEFAULT_MAP,
  605.                     DefaultColormap(display,
  606.                             DefaultScreen(display)),
  607.                     REDS_256-1,GREENS_256-1,BLUES_256-1));
  608.         if (!cm->colormap) {
  609.         /* That didn't work, try any map */
  610.         *cm = *(XmuStandardColormap(display,DefaultScreen(display),
  611.                         the_best->visual->visualid,
  612.                         the_best->depth,XA_RGB_BEST_MAP,
  613.                         (Colormap)NULL, REDS_256-1,
  614.                         GREENS_256-1,BLUES_256-1));
  615.         if (!cm->colormap)
  616.             break;
  617.         }
  618.         found = TRUE;
  619.         break;
  620.       case StaticColor:
  621.       case TrueColor:
  622.         /* Create an RGB_DEFAULT_MAP if values are correct */
  623.         if(the_best->visual->red_mask && the_best->visual->green_mask
  624.            && the_best->visual->blue_mask) {
  625.         std.colormap = DefaultColormap(display,
  626.                            DefaultScreen(display));
  627.         std.red_max = the_best->visual->red_mask;
  628.         std.red_mult = 1;
  629.         while(!(std.red_max & 0x01)) {
  630.             std.red_max >>= 1;
  631.             std.red_mult <<= 1;
  632.         }
  633.         std.green_max = the_best->visual->green_mask;
  634.         std.green_mult = 1;
  635.         while(!(std.green_max & 0x01)) {
  636.             std.green_max >>= 1;
  637.             std.green_mult <<= 1;
  638.         }
  639.         std.blue_max = the_best->visual->blue_mask;
  640.         std.blue_mult = 1;
  641.         while(!(std.blue_max & 0x01)) {
  642.             std.blue_max >>= 1;
  643.             std.blue_mult <<= 1;
  644.         }
  645.         std.base_pixel = 0;
  646.         std.visualid = the_best->visual->visualid;
  647.         std.killid = 0;
  648.         *cm = std;
  649.         found = TRUE;
  650.         }
  651.         break;
  652.     }
  653.     if (!found) {
  654.         XFree((caddr_t)available_visuals);
  655.         return(0);
  656.     }
  657.     }
  658.     *vs = *(the_best->visual);
  659.     *depth = the_best->depth;
  660.  
  661.     XFree((caddr_t)available_visuals);
  662.     return(1);
  663. }
  664.  
  665. SetVendorEntries()
  666. {
  667.  
  668.     /* Get the System name from the X Display Type entry */
  669.     BRF_appendToColon(brf_sysinfo[NSYSLN],ServerVendor(dpy));
  670.  
  671.     /* Get the number of bit Planes for this display */
  672.     sprintf(tmpln,"%ld Bit Planes",DisplayPlanes(dpy,DefaultScreen(dpy)));
  673.     BRF_appendToColon(brf_sysinfo[NHRDLN],tmpln);
  674.  
  675.     /* Use the Version and Revision numbers from the display */
  676.     sprintf(tmpln,"X%ldR%ld",ProtocolVersion(dpy),ProtocolRevision(dpy));
  677.     BRF_appendToColon(brf_sysinfo[NWNVLN],tmpln);
  678.  
  679.     /* Don't know how to generally get the OS name */
  680. #ifdef UTEK
  681.     BRF_appendToColon(brf_sysinfo[NOSVLN],"UTek");
  682. #endif /* UTEK */
  683. #ifdef UTEKV
  684.     BRF_appendToColon(brf_sysinfo[NOSVLN],"UTekV");
  685. #endif /* UTEK */
  686.  
  687.     /* Need to find out the real Timing Accuracy for this system
  688.      * Use the stopwatch function, this should be correct
  689.      */
  690.     sprintf(tmpln,"%.2lf ms",(double)stopwatch(WATCH_PRECISION));
  691.     BRF_appendToColon(brf_sysinfo[NTMALN],tmpln);
  692. }
  693.  
  694. CreateTheWindow(wkinfo,depth)
  695. Wk_info *wkinfo;
  696. int depth;
  697. {
  698.     static char *BIF_title = "NCGA Picture Level Benchmark";
  699.     static char *BIF_icon_name = "NCGA PLB";
  700.     XColor real;
  701.     XEvent evt;
  702.     int border_width;
  703.  
  704.     /* Set up default window attributes */
  705.     xswa.backing_store = NotUseful;
  706.     xswa.colormap = ci.colormap;
  707.     xswa.event_mask = ExposureMask | StructureNotifyMask;
  708.  
  709.     /* Check for user preference borderWidth */
  710.     border_width = 1;
  711.     (void *)strcpy(tmpln, Prog_name);
  712.     (void *)strcat(tmpln, ".borderWidth");
  713.     if (XrmGetResource(dis_db, tmpln, (char *)NULL, &str_type, &val)) {
  714.     if (sscanf(val.addr,"%i",&border_width) != 1)
  715.         border_width = 1;
  716.     }
  717.  
  718.     /* Check for user preference border color */
  719.     (void *)strcpy(tmpln, Prog_name);
  720.     (void *)strcat(tmpln, ".bordercolor");
  721.     if (XrmGetResource(dis_db, tmpln, (char *)NULL, &str_type, &val)) {
  722.     if(XParseColor(dpy, ci.colormap, val.addr, &real) == 0) {
  723.         xswa.border_pixel = CALC_COLOR_PIXEL(ci,
  724.                          (Pfloat)(real.red)/MXPIX,
  725.                          (Pfloat)(real.green)/MXPIX,
  726.                          (Pfloat)(real.blue)/MXPIX);
  727.     }
  728.     }
  729.     else
  730.     xswa.border_pixel = CALC_COLOR_PIXEL(ci,0.0,0.0,0.0);
  731.  
  732.     /* Check for user preference background color */
  733.     ur = ug = ub = 0.0;
  734.     user_background = FALSE;
  735.     (void *)strcpy(tmpln, Prog_name);
  736.     (void *)strcat(tmpln, ".background");
  737.     if (XrmGetResource(dis_db, tmpln, (char *)NULL, &str_type, &val)) {
  738.     if (XParseColor(dpy, ci.colormap, val.addr, &real)) {
  739.         ur = (Pfloat)real.red/MXPIX;
  740.         ug = (Pfloat)real.green/MXPIX;
  741.         ub = (Pfloat)real.blue/MXPIX;
  742.         user_background = TRUE;
  743.     }
  744.     }
  745.     xswa.background_pixel = CALC_COLOR_PIXEL(ci,ur,ug,ub);
  746.  
  747.     /* Check for user preference size and postition */
  748.     size_hints.flags = 0;
  749.     size_hints.x = size_hints.y = 100;
  750.     size_hints.width = wkinfo->x;
  751.     size_hints.height = wkinfo->y;
  752.  
  753.     (void *)strcpy(tmpln, Prog_name);
  754.     (void *)strcat(tmpln, ".geometry");
  755.     if (XrmGetResource(dis_db, tmpln, (char *)NULL, &str_type, &val)) {
  756.     char Geometry[20];
  757.     int bits, x, y;
  758.     unsigned int width, height;
  759.  
  760.     (void *)strcpy(Geometry, val.addr);
  761.     bits = XParseGeometry(Geometry, &x, &y, &width, &height);
  762.  
  763.     if (bits & (WidthValue)) {
  764.         size_hints.flags |= USSize;
  765.         size_hints.width = width;
  766.     }
  767.  
  768.     if (bits & (HeightValue)) {
  769.         size_hints.flags |= USSize;
  770.         size_hints.height = height;
  771.     }
  772.  
  773.     if (bits & XValue) {
  774.         if (bits & XNegative)
  775.         x = DisplayWidth(dpy, DefaultScreen(dpy)) +
  776.             x - size_hints.width;
  777.         size_hints.flags |= USPosition;
  778.         size_hints.x = x;
  779.     }
  780.  
  781.     if (bits & YValue) {
  782.         if (bits & YNegative)
  783.         y = DisplayHeight(dpy, DefaultScreen(dpy)) +
  784.             y - size_hints.height;
  785.         size_hints.flags |= USPosition;
  786.         size_hints.y = y;
  787.     }
  788.     }
  789.  
  790.     /* Create the window */
  791.     win = XCreateWindow(dpy, RootWindow(dpy, DefaultScreen(dpy)),
  792.             size_hints.x, size_hints.y, size_hints.width,
  793.             size_hints.height, border_width, depth,
  794.             InputOutput, &visual,
  795.             CWEventMask | CWColormap | CWBackingStore
  796.             | CWBorderPixel | CWBackPixel, &xswa);
  797.  
  798.     XSetStandardProperties( dpy, win, BIF_title, BIF_icon_name,
  799.                None, Argv, Argc, &size_hints );
  800.  
  801.     /*
  802.      * Set a standard colormap property on the root window. This is where
  803.      * the API expects to find it.
  804.      */
  805.     XSetRGBColormaps(dpy,RootWindow(dpy, DefaultScreen(dpy)),
  806.              &ci,1,XA_RGB_BEST_MAP);
  807.  
  808.     XMapWindow(dpy, win);
  809.  
  810.     do {
  811.     XNextEvent(dpy, &evt);
  812.     } while(evt.type != Expose);
  813.  
  814.     XSelectInput(dpy, win, (unsigned long)0);
  815. }
  816.  
  817. GetWorkstationInfo(ws, workid, wkinfo)
  818. Pint ws;
  819. Pint workid;
  820. Wk_info *wkinfo;
  821. {
  822.     Pws_tables_plus gpc_ws_tables;
  823.     Pint err_ind,length,lin_len,shd_len,refl_len,hat_len;
  824.     Pint_list gpc_inq_int_list;
  825.     Pint gpc_inq_ints[LIST_SIZE];
  826.     Pint hlhsr_mode;
  827.     Pmarker_facs gpc_marker_facs;
  828.     Pline_facs_plus gpc_ext_line_facs;
  829.     Pint_facs_plus gpc_ext_int_facs;
  830.     Pedge_facs gpc_edge_facs;
  831.     int listptr;
  832.     int i,j;
  833.  
  834.     pset_colr_model((Pint)workid, (Pint)wkinfo->color_model);
  835.  
  836.     pinq_ws_st_table_plus(ws,&err_ind,&gpc_ws_tables);
  837.     wkinfo->cmap_size = gpc_ws_tables.colr_reps - 2;
  838.     wkinfo->view_size = gpc_ws_tables.view_reps - 1;
  839.     wkinfo->dcue_size = gpc_ws_tables.dcue_rep - 1;
  840.     wkinfo->light_size = gpc_ws_tables.light_src_rep;
  841.  
  842.     /* Set up exceptions based on workstation facilities */
  843.     listptr = brf_num_ex_tests; /* get the number of messages */
  844.  
  845.     /* Marker Exceptions */
  846.     pinq_marker_facs(ws,0,0,&err_ind,&gpc_marker_facs,&length);
  847.     if (!err_ind && (length < LIST_SIZE)) {
  848.     gpc_marker_facs.types.ints = gpc_inq_ints;
  849.     pinq_marker_facs(ws,length,0,&err_ind,&gpc_marker_facs,
  850.              &length);
  851.  
  852.     for (i=0;i < NUM_MARKER_TYPES;i++) {
  853.         for (j=0;j < gpc_marker_facs.types.num_ints;j++) {
  854.         if (gpc_marker_facs.types.ints[j] == marker_types[i].type)
  855.             break;
  856.         }
  857.         if (j == gpc_marker_facs.types.num_ints) {
  858.         LIST_INVERT_IRANGE(MARKER_TYPE,BRF_WARNING,
  859.                    marker_types[i].type,
  860.                    marker_types[i].type,BRF_intrange,
  861.                    marker_types[i].type_string);
  862.         }
  863.     }
  864.  
  865.     LIST_RRANGE(MARKER_SIZE,BRF_WARNING,gpc_marker_facs.min_size,
  866.             gpc_marker_facs.max_size,BRF_realrange,
  867.             "MARKER_WIDTH Scale_factor(s) not supported.\n");
  868.     }
  869.  
  870.     /* Line Exceptions */
  871.     pinq_line_facs_plus(ws,0,0,0,0,&err_ind,&lin_len,&shd_len,
  872.             &gpc_ext_line_facs);
  873.     if (!err_ind && ((lin_len + shd_len) < LIST_SIZE)) {
  874.     gpc_ext_line_facs.types.ints = gpc_inq_ints;
  875.     gpc_ext_line_facs.shads.ints = &gpc_inq_ints[lin_len];
  876.     pinq_line_facs_plus(ws,lin_len,0,shd_len,0,&err_ind,
  877.                 &lin_len,&shd_len,&gpc_ext_line_facs);
  878.  
  879.     for (i=0;i < NUM_LINE_TYPES;i++) {
  880.         for (j=0;j < gpc_ext_line_facs.types.num_ints;j++) {
  881.         if (gpc_ext_line_facs.types.ints[j] == line_types[i].type)
  882.             break;
  883.         }
  884.         if (j == gpc_ext_line_facs.types.num_ints) {
  885.         LIST_INVERT_IRANGE(LINE_TYPE,BRF_WARNING,
  886.                    line_types[i].type,
  887.                    line_types[i].type,BRF_intrange,
  888.                    line_types[i].type_string);
  889.         }
  890.     }
  891.  
  892.     for (i=0;i < NUM_LINE_SHADES;i++) {
  893.         for (j=0;j < gpc_ext_line_facs.shads.num_ints;j++) {
  894.         if (gpc_ext_line_facs.shads.ints[j] == line_shades[i].type)
  895.             break;
  896.         }
  897.         if (j == gpc_ext_line_facs.shads.num_ints) {
  898.         LIST_INVERT_IRANGE(LINE_SHADING,BRF_WARNING,
  899.                    line_shades[i].type,
  900.                    line_shades[i].type,BRF_intrange,
  901.                    line_shades[i].type_string);
  902.         }
  903.     }
  904.  
  905.     LIST_RRANGE(LINE_WIDTH,BRF_WARNING,gpc_ext_line_facs.min_width,
  906.             gpc_ext_line_facs.max_width,BRF_realrange,
  907.             "LINE_WIDTH Scale_factor(s) not supported.\n");
  908.     }
  909.  
  910.     /* Pattern Index Exceptions */
  911.     pinq_pat_facs(ws,&err_ind,&length);
  912.     if (!err_ind && length) {
  913.     LIST_IRANGE(INTERIOR_PATTERN_INDEX,BRF_WARNING,0,length,
  914.             BRF_intrange,
  915.             "INTERIOR_PATTERN_INDEX not supported.\n");
  916.     }
  917.     else {
  918.     LIST_NONSUP(INTERIOR_PATTERN_INDEX,BRF_ERROR,
  919.             "INTERIOR_PATTERN_INDEX not supported.\n");
  920.     }
  921.  
  922.     /* Interior Exceptions */
  923.     pinq_int_facs_plus(ws,0,0,0,0,0,0,0,0,&err_ind,
  924.                &gpc_ext_int_facs,&lin_len,&hat_len,
  925.                &refl_len,&shd_len);
  926.     if (!err_ind && ((lin_len + refl_len + shd_len) < LIST_SIZE)) {
  927.     gpc_ext_int_facs.int_styles = (Pint_style *)&gpc_inq_ints[0];
  928.     gpc_ext_int_facs.refl_eqns.ints = &gpc_inq_ints[lin_len];
  929.     gpc_ext_int_facs.shad_meths.ints = &gpc_inq_ints[lin_len+refl_len];
  930.     pinq_int_facs_plus(ws,lin_len,0,0,0,refl_len,0,shd_len,0,
  931.                &err_ind,&gpc_ext_int_facs,&lin_len,&hat_len,
  932.                &refl_len,&shd_len);
  933.  
  934.     for (i=0;i < NUM_INTERIOR_TYPES;i++) {
  935.         for (j=0;j < gpc_ext_int_facs.num_int_styles;j++) {
  936.         if (gpc_ext_int_facs.int_styles[j] == interior_types[i].type)
  937.             break;
  938.         }
  939.         if (j == gpc_ext_int_facs.num_int_styles) {
  940.         LIST_INVERT_IRANGE(INTERIOR_STYLE,BRF_WARNING,
  941.                    interior_types[i].type,
  942.                    interior_types[i].type,BRF_intrange,
  943.                    interior_types[i].type_string);
  944.         }
  945.     }
  946.  
  947.     for (i=0;i < NUM_INTERIOR_REFLECS;i++) {
  948.         for (j=0;j < gpc_ext_int_facs.refl_eqns.num_ints;j++) {
  949.         if (gpc_ext_int_facs.refl_eqns.ints[j] ==
  950.             interior_reflecs[i].type)
  951.             break;
  952.         }
  953.         if (j == gpc_ext_int_facs.refl_eqns.num_ints) {
  954.         LIST_INVERT_IRANGE(INTERIOR_LIGHTING,BRF_WARNING,
  955.                    interior_reflecs[i].type,
  956.                    interior_reflecs[i].type,BRF_intrange,
  957.                    interior_reflecs[i].type_string);
  958.         }
  959.     }
  960.  
  961.     for (i=0;i < NUM_INTERIOR_SHADES;i++) {
  962.         for (j=0;j < gpc_ext_int_facs.shad_meths.num_ints;j++) {
  963.         if (gpc_ext_int_facs.shad_meths.ints[j] ==
  964.             interior_shade_types[i].type)
  965.             break;
  966.         }
  967.         if (j == gpc_ext_int_facs.shad_meths.num_ints) {
  968.         LIST_INVERT_IRANGE(INTERIOR_SHADING,BRF_WARNING,
  969.                    interior_shade_types[i].type,
  970.                    interior_shade_types[i].type,
  971.                    BRF_intrange,
  972.                    interior_shade_types[i].type_string);
  973.         }
  974.     }
  975.     }
  976.  
  977.     /* Edge Exceptions */
  978.     pinq_edge_facs(ws,0,0,&err_ind,&gpc_edge_facs,&length);
  979.     if (!err_ind && (length < LIST_SIZE)) {
  980.     gpc_edge_facs.types.ints = gpc_inq_ints;
  981.     pinq_edge_facs(ws,length,0,&err_ind,&gpc_edge_facs,
  982.                &length);
  983.  
  984.     for (i=0;i < NUM_EDGE_TYPES;i++) {
  985.         for (j=0;j < gpc_edge_facs.types.num_ints;j++) {
  986.         if (gpc_edge_facs.types.ints[j] == edge_types[i].type)
  987.             break;
  988.         }
  989.         if (j == gpc_edge_facs.types.num_ints) {
  990.         LIST_INVERT_IRANGE(EDGE_TYPE,BRF_WARNING,
  991.                    edge_types[i].type,
  992.                    edge_types[i].type,BRF_intrange,
  993.                    edge_types[i].type_string);
  994.         }
  995.     }
  996.  
  997.     LIST_RRANGE(EDGE_WIDTH,BRF_WARNING,gpc_edge_facs.min_width,
  998.             gpc_edge_facs.max_width,BRF_realrange,
  999.             "EDGE_WIDTH Scale_factor(s) not supported.\n");
  1000.     }
  1001.  
  1002.     /* NURB Exceptions */
  1003.     /*
  1004.      * There currently is no support for NURBs.
  1005.      * The API does not have an interface for SET TRIMMING CURVE
  1006.      * APPROXIMATION CRITERIA, and the PLB is not settled on the
  1007.      * enumeration for APPROXIMATION CRITERIA.
  1008.      */
  1009.     LIST_NONSUP(CURVE_APPROXIMATION_CRITERIA,BRF_ERROR,
  1010.         "CURVE_APPROXIMATION_CRITERIA not supported.\n");
  1011.     LIST_NONSUP(SURFACE_APPROXIMATION_CRITERIA,BRF_ERROR,
  1012.         "SURFACE_APPROXIMATION_CRITERIA not supported.\n");
  1013.     LIST_NONSUP(TRIMCURVE_APPROXIMATION_CRITERIA,BRF_ERROR,
  1014.         "TRIMCURVE_APPROXIMATION_CRITERIA not supported.\n");
  1015.     LIST_NONSUP(NON_UNIFORM_BSPLINE_CURVE,BRF_ERROR,
  1016.         "NON_UNIFORM_BSPLINE_CURVE not supported.\n");
  1017.     LIST_NONSUP(NON_UNIFORM_BSPLINE_SURFACE,BRF_ERROR,
  1018.         "NON_UNIFORM_BSPLINE_SURFACE not supported.\n");
  1019.  
  1020. /*----------------------------------------------------------------------*\
  1021. |     Global Enable Hidden Surface Removal
  1022. \*----------------------------------------------------------------------*/
  1023.  
  1024.     /* Inquire on the Hidden Surface Removal type and set to an
  1025.        appropriate value. Preferred is PHIGS_HLHSR_MODE_ZBUFF. */
  1026.     hlhsr_mode = PHIGS_HLHSR_MODE_ZBUFF;
  1027.  
  1028.     /* Find out if the user wants a different mode */
  1029.     (void *)strcpy(tmpln, Prog_name);
  1030.     (void *)strcat(tmpln, ".hlhsrMode");
  1031.     if (XrmGetResource(dis_db, tmpln, (char *)NULL, &str_type, &val)) {
  1032.     upcase(val.addr,tmpln);
  1033.     for (i = 0;i < NUM_HLHSR_MODES;i++) {
  1034.         if (!strcmp(tmpln,hlhsr_modes[i])) {
  1035.         hlhsr_mode = (Pint)i;
  1036.         break;
  1037.         }
  1038.     }
  1039.     }
  1040.  
  1041.     gpc_inq_int_list.ints = gpc_inq_ints;
  1042.     pinq_hlhsr_mode_facs(ws,LIST_SIZE,0,&err_ind,&gpc_inq_int_list,
  1043.              &length);
  1044.     if (!err_ind) {
  1045.     for (i = 0;i < gpc_inq_int_list.num_ints;i++) {
  1046.         if (gpc_inq_int_list.ints[i] == hlhsr_mode) {
  1047.         pset_hlhsr_mode(workid,hlhsr_mode);
  1048.         break;
  1049.         }
  1050.     }
  1051.     if ( i == gpc_inq_int_list.num_ints ) {
  1052.         LIST_INVERT_IRANGE(HLHS_REMOVAL,BRF_WARNING,
  1053.                    BIF_HLHS_ENABLE,BIF_HLHS_ENABLE,
  1054.                    BRF_intrange,
  1055.                    "HLHS_REMOVAL not supported.\n");
  1056.         LIST_INVERT_IRANGE(HLHSRID,BRF_WARNING,
  1057.                    BIF_HLHS_ENABLE,BIF_HLHS_ENABLE,
  1058.                    BRF_intrange,
  1059.                    "HLHSRID not supported.\n");
  1060.     }
  1061.     }
  1062.  
  1063.     brf_num_ex_tests = listptr; /* save the number of messages */
  1064. }
  1065.  
  1066. SetDefaultColors(work_id)
  1067. Pint work_id;
  1068. {
  1069.     Pint indx;
  1070.     Pcolr_rep rep;
  1071.  
  1072.     /* Map location 0, background color */
  1073.     indx = 0; rep.rgb.red = ur; rep.rgb.green = ug; rep.rgb.blue = ub;
  1074.     pset_colr_rep(work_id, indx, &rep);
  1075.  
  1076.     /* Map location 1, color Black */
  1077.     indx = 1; rep.rgb.red = 0.0; rep.rgb.green = 0.0; rep.rgb.blue = 0.0;
  1078.     pset_colr_rep(work_id, indx, &rep);
  1079.  
  1080.     /* Map location 2, color White */
  1081.     indx = 2; rep.rgb.red = 1.0; rep.rgb.green = 1.0; rep.rgb.blue = 1.0;
  1082.     pset_colr_rep(work_id, indx, &rep);
  1083.  
  1084.     /* Map location 3, color Red */
  1085.     indx = 3; rep.rgb.red = 1.0; rep.rgb.green = 0.0; rep.rgb.blue = 0.0;
  1086.     pset_colr_rep(work_id, indx, &rep);
  1087.  
  1088.     /* Map location 4, color Green */
  1089.     indx = 4; rep.rgb.red = 0.0; rep.rgb.green = 1.0; rep.rgb.blue = 0.0;
  1090.     pset_colr_rep(work_id, indx, &rep);
  1091.  
  1092.     /* Map location 5, color Blue */
  1093.     indx = 5; rep.rgb.red = 0.0; rep.rgb.green = 0.0; rep.rgb.blue = 1.0;
  1094.     pset_colr_rep(work_id, indx, &rep);
  1095.  
  1096.     /* Map location 6, color Cyan */
  1097.     indx = 6; rep.rgb.red = 0.0; rep.rgb.green = 1.0; rep.rgb.blue = 1.0;
  1098.     pset_colr_rep(work_id, indx, &rep);
  1099.  
  1100.     /* Map location 7, color Magenta */
  1101.     indx = 7;  rep.rgb.red = 1.0; rep.rgb.green = 0.0; rep.rgb.blue = 1.0;
  1102.     pset_colr_rep(work_id, indx, &rep);
  1103.  
  1104.     /* Map location 8, color Yellow */
  1105.     indx = 8; rep.rgb.red = 1.0; rep.rgb.green = 1.0; rep.rgb.blue = 0.0;
  1106.     pset_colr_rep(work_id, indx, &rep);
  1107.  
  1108. }
  1109. #endif /* USING_PHIGS */
  1110.