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.13 by greg, Tue Oct 3 13:02:57 1989 UTC vs.
Revision 1.17 by greg, Wed Oct 25 17:17:09 1989 UTC

# Line 67 | Line 67 | static int  c_last = 0;                        /* last character in queue *
67  
68   extern char  *malloc();
69  
70 int  xnewcolr();
71
70   int  x_close(), x_clear(), x_paintr(), x_errout(),
71                  x_getcur(), x_comout(), x_comin();
72  
# Line 80 | Line 78 | static struct driver  x_driver = {
78  
79  
80   struct driver *
81 < x_init(name)                    /* initialize driver */
82 < char  *name;
81 > x_init(name, id)                /* initialize driver */
82 > char  *name, *id;
83   {
84          ourdisplay = XOpenDisplay(NULL);
85          if (ourdisplay == NULL) {
# Line 92 | Line 90 | char  *name;
90                  stderr_v("not enough colors\n");
91                  return(NULL);
92          }
93 <        make_cmap(GAMMA);                       /* make color map */
96 <        if (getpixels() < 0)                    /* get pixels */
97 <                stderr_v("cannot allocate colors\n");
93 >        make_gmap(GAMMA);                       /* make color map */
94  
95          pickcursor = XCreateCursor(bcross_width, bcross_height,
96                          bcross_bits, bcross_mask_bits,
97                          bcross_x_hot, bcross_y_hot,
98                          BlackPixel, WhitePixel, GXcopy);
99 <        clientname = name;
99 >        clientname = id;
100          x_driver.inpready = 0;
101          cmdvec = x_comout;                      /* set error vectors */
102          if (wrnvec != NULL)
# Line 140 | Line 136 | int  xres, yres;
136          if (xres != gwidth || yres != gheight) {        /* new window */
137                  if (comline != NULL)
138                          xt_close(comline);
139 <                if (gwind != 0)
140 <                        XDestroyWindow(gwind);
141 <                gwind = XCreateWindow(RootWindow, 0, BARHEIGHT,
142 <                                xres, yres+COMHEIGHT, BORWIDTH,
143 <                                BlackPixmap, BlackPixmap);
144 <                if (gwind == 0)
145 <                        goto fail;
139 >                if (gwind == 0) {
140 >                        gwind = XCreateWindow(RootWindow, 0, BARHEIGHT,
141 >                                        xres, yres+COMHEIGHT, BORWIDTH,
142 >                                        BlackPixmap, BlackPixmap);
143 >                        if (gwind == 0)
144 >                                goto fail;
145 >                        XStoreName(gwind, clientname);
146 >                        XSelectInput(gwind, KeyPressed|ButtonPressed|
147 >                                        ExposeWindow|ExposeRegion|UnmapWindow);
148 >                        XMapWindow(gwind);
149 >                } else
150 >                        XChangeWindow(gwind, xres, yres+COMHEIGHT);
151                  comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN);
152                  if (comline == NULL)
153                          goto fail;
153                XMapWindow(gwind);
154                XSelectInput(gwind,
155        KeyPressed|ButtonPressed|ExposeWindow|ExposeRegion|UnmapWindow);
156                XStoreName(gwind, clientname);
154                  gwidth = xres;
155                  gheight = yres;
156          } else                                          /* just clear */
157                  XClear(gwind);
158 <        if (new_ctab(ncolors, xnewcolr) == 0) {
159 <                stderr_v("Color allocation error\n");
160 <                quit(1);
161 <        }
162 <        checkinp();
158 >                                                /* reinitialize color table */
159 >        if (ncolors == 0 && getpixels() == 0)
160 >                stderr_v("cannot allocate colors\n");
161 >        else
162 >                new_ctab(ncolors);
163 >        XSync(1);                               /* discard input */
164          return;
165   fail:
166          stderr_v("Failure opening window in x_clear\n");
# Line 176 | Line 174 | COLOR  col;
174   int  xmin, ymin, xmax, ymax;
175   {
176          extern long  nrays;             /* global ray count */
177 +        extern int  xnewcolr();         /* pixel assignment routine */
178          static long  lastflush = 0;     /* ray count at last flush */
179  
180          if (ncolors > 0) {
181                  XPixSet(gwind, xmin, gheight-ymax, xmax-xmin, ymax-ymin,
182 <                                pixval[get_pixel(col)]);
182 >                                pixval[get_pixel(col, xnewcolr)]);
183          }
184          if (nrays - lastflush >= WFLUSH) {
185                  if (ncolors <= 0)       /* output necessary for death */
# Line 268 | Line 267 | int  r, g, b;
267   }
268  
269  
270 < static
270 > static int
271   getpixels()                             /* get the color map */
272   {
273          int  planes;
274  
275 +        freepixels();
276          for (ncolors=(1<<DisplayPlanes())-3; ncolors>12; ncolors=ncolors*.937){
277                  pixval = (int *)malloc(ncolors*sizeof(int));
278                  if (pixval == NULL)
279                          break;
280                  if (XGetColorCells(0,ncolors,0,&planes,pixval) != 0)
281 <                        return(0);
281 >                        return(ncolors);
282                  free((char *)pixval);
283          }
284 <        ncolors = 0;
285 <        return(-1);
284 >        return(ncolors = 0);
285   }
286  
287  
# Line 319 | Line 318 | getevent()                     /* get next event */
318                  break;
319          case ExposeWindow:
320                  if (levptr(XExposeEvent)->subwindow == 0) {
321 <                        if (ncolors == 0 && getpixels() < 0) {
321 >                        if (ncolors == 0 && getpixels() == 0) {
322                                  stderr_v("cannot allocate colors\n");
323                                  break;
324                          }
325 <                        new_ctab(ncolors, xnewcolr);
325 >                        new_ctab(ncolors);
326                  }
327                  /* fall through */
328          case ExposeRegion:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines