ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/x10.c
(Generate patch)

Comparing ray/src/rt/x10.c (file contents):
Revision 1.26 by greg, Fri Feb 23 08:55:18 1990 UTC vs.
Revision 2.6 by gregl, Tue Nov 11 20:03:02 1997 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *     5/7/87
11   */
12  
13 < #include  <stdio.h>
13 > #include  "standard.h"
14  
15 #include  <sys/ioctl.h>
16
15   #include  <X/Xlib.h>
16   #include  <X/cursors/bcross.cursor>
17   #include  <X/cursors/bcross_mask.cursor>
# Line 61 | Line 59 | extern char  *malloc(), *getcombuf();
59  
60   extern char  *progname;
61  
62 < int  x_close(), x_clear(), x_paintr(), x_errout(),
62 > static int  x_close(), x_clear(), x_paintr(), x_errout(),
63                  x_getcur(), x_comout(), x_comin(), x_flush();
64  
65   static struct driver  x_driver = {
# Line 74 | Line 72 | struct driver *
72   x_init(name, id)                /* initialize driver */
73   char  *name, *id;
74   {
75 +        extern char  *getenv();
76 +        char  *gv;
77          char  defgeom[32];
78          OpaqueFrame  mainframe;
79  
80          ourdisplay = XOpenDisplay(NULL);
81          if (ourdisplay == NULL) {
82 <                stderr_v("cannot open X-windows; DISPLAY variable set?\n");
82 >                eputs("cannot open X-windows; DISPLAY variable set?\n");
83                  return(NULL);
84          }
85          if (DisplayPlanes() < 4) {
86 <                stderr_v("not enough colors\n");
86 >                eputs("not enough colors\n");
87                  return(NULL);
88          }
89 <        make_gmap(GAMMA);                       /* make color map */
89 >                                /* make color map */
90 >        if ((gv = getenv("DISPLAY_GAMMA")) != NULL)
91 >                make_gmap(atof(gv));
92 >        else
93 >                make_gmap(GAMMA);
94  
95          pickcursor = XCreateCursor(bcross_width, bcross_height,
96                          bcross_bits, bcross_mask_bits,
# Line 100 | Line 104 | char  *name, *id;
104          gwind = XCreate("X10 display driver", progname, NULL, defgeom,
105                          &mainframe, MINWIDTH, MINHEIGHT+COMHEIGHT);
106          if (gwind == 0) {
107 <                stderr_v("can't create window\n");
107 >                eputs("can't create window\n");
108                  return(NULL);
109          }
110          XStoreName(gwind, id);
# Line 111 | Line 115 | char  *name, *id;
115          x_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
116          x_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
117          x_driver.inpready = 0;
118 <        cmdvec = x_comout;                      /* set error vectors */
119 <        if (wrnvec != NULL)
120 <                wrnvec = x_errout;
118 >        erract[COMMAND].pf = x_comout;          /* set error vectors */
119 >        if (erract[WARNING].pf != NULL)
120 >                erract[WARNING].pf = x_errout;
121          return(&x_driver);
122   }
123  
# Line 121 | Line 125 | char  *name, *id;
125   static
126   x_close()                       /* close our display */
127   {
128 <        cmdvec = NULL;                          /* reset error vectors */
129 <        if (wrnvec != NULL)
130 <                wrnvec = stderr_v;
128 >        erract[COMMAND].pf = NULL;              /* reset error vectors */
129 >        if (erract[WARNING].pf != NULL)
130 >                erract[WARNING].pf = wputs;
131          if (ourdisplay == NULL)
132                  return;
133          if (comline != NULL) {
# Line 146 | Line 150 | x_clear(xres, yres)                    /* clear our display */
150   int  xres, yres;
151   {
152          if (xres != gwidth || yres != gheight) {        /* new window */
149                if (comline != NULL)
150                        xt_close(comline);
153                  XChangeWindow(gwind, xres, yres+COMHEIGHT);
152                comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN);
153                if (comline == NULL) {
154                        stderr_v("Cannot open command line window\n");
155                        quit(1);
156                }
154                  gwidth = xres;
155                  gheight = yres;
156          } else                                          /* just clear */
157                  XClear(gwind);
158                                                  /* reinitialize color table */
159          if (getpixels() == 0)
160 <                stderr_v("cannot allocate colors\n");
160 >                eputs("cannot allocate colors\n");
161          else
162                  new_ctab(ncolors);
163 <
163 >                                                /* open new command line */
164 >        if (comline != NULL)
165 >                xt_close(comline);
166 >        comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN);
167 >        if (comline == NULL) {
168 >                eputs("Cannot open command line window\n");
169 >                quit(1);
170 >        }
171          XMapWindow(gwind);                      /* make sure it's mapped */
172          XSync(1);                               /* discard input */
173          return;
# Line 199 | Line 203 | static
203   x_comin(inp, prompt)            /* read in a command line */
204   char  *inp, *prompt;
205   {
206 <        int  x_getc(), x_comout();
206 >        extern int  x_getc();
207  
208          if (prompt != NULL)
209                  if (fromcombuf(inp, &x_driver))
# Line 216 | Line 220 | static
220   x_comout(out)                   /* output a string to command line */
221   char  *out;
222   {
223 <        if (comline != NULL)
224 <                xt_puts(out, comline);
225 <        XFlush();
223 >        if (comline == NULL)
224 >                return;
225 >        xt_puts(out, comline);
226 >        if (out[strlen(out)-1] == '\n')
227 >                XFlush();
228   }
229  
230  
# Line 226 | Line 232 | static
232   x_errout(msg)                   /* output an error message */
233   char  *msg;
234   {
235 +        eputs(msg);             /* send to stderr also! */
236          x_comout(msg);
230        stderr_v(msg);          /* send to stderr also! */
237   }
238  
239  
# Line 362 | Line 368 | register XExposeEvent  *eexp;
368          }
369                                          /* remap colors */
370          if (getpixels() == 0) {
371 <                stderr_v("cannot allocate colors\n");
371 >                eputs("cannot allocate colors\n");
372                  return;
373          }
374          new_ctab(ncolors);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines