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.12 by greg, Mon Oct 2 17:12:39 1989 UTC vs.
Revision 1.13 by greg, Tue Oct 3 13:02:57 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 +
72   int  x_close(), x_clear(), x_paintr(), x_errout(),
73                  x_getcur(), x_comout(), x_comin();
74  
# Line 156 | Line 158 | int  xres, yres;
158                  gheight = yres;
159          } else                                          /* just clear */
160                  XClear(gwind);
161 <        if (newtab() < 0) {
161 >        if (new_ctab(ncolors, xnewcolr) == 0) {
162                  stderr_v("Color allocation error\n");
163                  quit(1);
164          }
# Line 251 | Line 253 | int  *xp, *yp;
253  
254  
255   static
256 < newcolr(ndx, clr)               /* enter a color into hardware table */
256 > xnewcolr(ndx, r, g, b)          /* enter a color into hardware table */
257   int  ndx;
258 < COLR  clr;
258 > int  r, g, b;
259   {
260          Color  xcolor;
261  
262          xcolor.pixel = pixval[ndx];
263 <        xcolor.red = clr[RED] << 8;
264 <        xcolor.green = clr[GRN] << 8;
265 <        xcolor.blue = clr[BLU] << 8;
263 >        xcolor.red = r << 8;
264 >        xcolor.green = g << 8;
265 >        xcolor.blue = b << 8;
266  
267          XStoreColor(&xcolor);
268   }
269  
270  
271   static
270 newtab()                        /* assign new color table */
271 {
272        extern COLR     *get_ctab();
273        COLR    *ctab;
274        Color   *defs;
275        register int    i;
276
277        if ((ctab = get_ctab(ncolors)) == NULL)
278                return(-1);
279        if ((defs = (Color *)malloc(ncolors*sizeof(Color))) == NULL)
280                return(-1);
281        for (i = 0; i < ncolors; i++) {
282                defs[i].pixel = pixval[i];
283                defs[i].red = ctab[i][RED] << 8;
284                defs[i].green = ctab[i][GRN] << 8;
285                defs[i].blue = ctab[i][BLU] << 8;
286        }
287        XStoreColors(ncolors, defs);
288        free((char *)defs);
289        return(0);
290 }
291
292
293 static
272   getpixels()                             /* get the color map */
273   {
274          int  planes;
# Line 340 | Line 318 | getevent()                     /* get next event */
318                  getkey(levptr(XKeyPressedEvent));
319                  break;
320          case ExposeWindow:
321 <                if (ncolors == 0 && levptr(XExposeEvent)->subwindow == 0)
322 <                        if (getpixels() < 0)
323 <                                stderr_v("cannot grab colors\n");
324 <                        else
325 <                                newtab();
321 >                if (levptr(XExposeEvent)->subwindow == 0) {
322 >                        if (ncolors == 0 && getpixels() < 0) {
323 >                                stderr_v("cannot allocate colors\n");
324 >                                break;
325 >                        }
326 >                        new_ctab(ncolors, xnewcolr);
327 >                }
328                  /* fall through */
329          case ExposeRegion:
330                  fixwindow(levptr(XExposeEvent));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines