home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / pexdraw / part12 < prev    next >
Encoding:
Text File  |  1993-06-07  |  59.9 KB  |  1,572 lines

  1. Newsgroups: comp.sources.x
  2. From: jch@okimicro.oki.com (Jan Hardenbergh)
  3. Subject: v20i022:  pexdraw - A PEX drawing program, Part12/14
  4. Message-ID: <1993Jun8.150241.19399@sparky.imd.sterling.com>
  5. X-Md4-Signature: e2b20327788d75432f344528206c582b
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 8 Jun 1993 15:02:41 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: jch@okimicro.oki.com (Jan Hardenbergh)
  12. Posting-number: Volume 20, Issue 22
  13. Archive-name: pexdraw/part12
  14. Environment: X11R5, PEX
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  XMU/CrCmap.c teapotc.3 util/pexutdbint.c util/pexutdbint.h
  21. # Wrapped by chris@sparky on Tue Jun  8 09:46:35 1993
  22. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 12 (of 14)."'
  25. if test -f 'XMU/CrCmap.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'XMU/CrCmap.c'\"
  27. else
  28.   echo shar: Extracting \"'XMU/CrCmap.c'\" \(17396 characters\)
  29.   sed "s/^X//" >'XMU/CrCmap.c' <<'END_OF_FILE'
  30. X#ifdef SCCS
  31. Xstatic char sccsid[]="@(#)CrCmap.c    1.4 Oki 92/11/30";
  32. X#endif
  33. X/*
  34. X    This file is under sccs control at Oki in:
  35. X    /nfs/sole/root/sccs1.p/X11R5/mit/lib/Xmu/s.CrCmap.c
  36. X*/
  37. X/* $XConsortium: CrCmap.c,v 1.5 92/11/24 14:40:47 rws Exp $
  38. X *
  39. X * CreateCmap.c - given a standard colormap description, make the map.
  40. X * 
  41. X * Copyright 1989 by the Massachusetts Institute of Technology
  42. X *
  43. X * Permission to use, copy, modify, and distribute this software and its
  44. X * documentation for any purpose and without fee is hereby granted, provided 
  45. X * that the above copyright notice appear in all copies and that both that 
  46. X * copyright notice and this permission notice appear in supporting 
  47. X * documentation, and that the name of M.I.T. not be used in advertising
  48. X * or publicity pertaining to distribution of the software without specific, 
  49. X * written prior permission. M.I.T. makes no representations about the 
  50. X * suitability of this software for any purpose.  It is provided "as is"
  51. X * without express or implied warranty.
  52. X *
  53. X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  54. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  55. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  56. X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  57. X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  58. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  59. X *
  60. X * Author:  Donna Converse, MIT X Consortium
  61. X */
  62. X
  63. X#include <stdio.h>
  64. X#include <X11/Xlib.h>
  65. X#include <X11/Xutil.h>
  66. X
  67. Xextern char    *calloc();
  68. X
  69. Xstatic int    ROmap();        /* allocate entire map Read Only */
  70. Xstatic Status    ROorRWcell();        /* allocate a cell, prefer Read Only */
  71. Xstatic Status    RWcell();        /* allocate a cell Read Write */
  72. Xstatic int    compare();        /* for quicksort */
  73. Xstatic Status     contiguous();        /* find contiguous sequence of cells */
  74. Xstatic void    free_cells();        /* frees resources before quitting */
  75. Xstatic Status    readonly_map();        /* create a map in a RO visual type */
  76. Xstatic Status    readwrite_map();    /* create a map in a RW visual type */
  77. X
  78. X#define lowbit(x) ((x) & (~(x) + 1))
  79. X#define TRUEMATCH(mult,max,mask) \
  80. X    (colormap->max * colormap->mult <= vinfo->mask && \
  81. X     lowbit(vinfo->mask) == colormap->mult)
  82. X
  83. X/*
  84. X * To create any one colormap which is described by an XStandardColormap
  85. X * structure, use XmuCreateColormap().
  86. X *
  87. X * Return 0 on failure, non-zero on success.
  88. X * Resources created by this function are not made permanent.
  89. X * No argument error checking is provided.  Use at your own risk.
  90. X *
  91. X * All colormaps are created with read only allocations, with the exception
  92. X * of read only allocations of colors in the default map or otherwise
  93. X * which fail to return the expected pixel value, and these are individually 
  94. X * defined as read/write allocations.  This is done so that all the cells
  95. X * defined in the default map are contiguous, for use in image processing.
  96. X * This typically happens with White and Black in the default map.
  97. X *
  98. X * Colormaps of static visuals are considered to be successfully created if
  99. X * the map of the static visual matches the definition given in the
  100. X * standard colormap structure.
  101. X */
  102. X   
  103. XStatus XmuCreateColormap(dpy, colormap)
  104. X    Display        *dpy;        /* specifies the connection under 
  105. X                     * which the map is created */
  106. X    XStandardColormap    *colormap;    /* specifies the map to be created,
  107. X                     * and returns, particularly if the
  108. X                     * map is created as a subset of the
  109. X                     * default colormap of the screen,
  110. X                     * the base_pixel of the map.
  111. X                     */
  112. X{
  113. X    XVisualInfo        vinfo_template;    /* template visual information */
  114. X    XVisualInfo        *vinfo;        /* matching visual information */
  115. X    XVisualInfo        *vpointer;    /* for freeing the entire list */
  116. X    long        vinfo_mask;    /* specifies the visual mask value */
  117. X    int         n;        /* number of matching visuals */
  118. X    int            status;        
  119. X
  120. X    vinfo_template.visualid = colormap->visualid;
  121. X    vinfo_mask = VisualIDMask;
  122. X    if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
  123. X    return 0;
  124. X
  125. X    /* A visual id may be valid on multiple screens.  Also, there may 
  126. X     * be multiple visuals with identical visual ids at different depths.  
  127. X     * If the colormap is the Default Colormap, use the Default Visual.
  128. X     * Otherwise, arbitrarily, use the deepest visual.
  129. X     */
  130. X    vpointer = vinfo;
  131. X    if (n > 1)
  132. X    {
  133. X    register int    i;
  134. X    register int    screen_number;
  135. X    Bool         def_cmap;
  136. X
  137. X    def_cmap = False;
  138. X    for (screen_number = ScreenCount(dpy); --screen_number >= 0; )
  139. X        if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
  140. X        def_cmap = True;
  141. X        break;
  142. X        }
  143. X
  144. X    if (def_cmap) {
  145. X        for (i=0; i < n; i++, vinfo++) {
  146. X        if (vinfo->visual == DefaultVisual(dpy, screen_number))
  147. X            break;
  148. X        }
  149. X    } else {
  150. X        unsigned int    maxdepth = 0;
  151. X        XVisualInfo        *v;
  152. X
  153. X        for (i=0; i < n; i++, vinfo++)
  154. X        if (vinfo->depth > maxdepth) {
  155. X            maxdepth = vinfo->depth;
  156. X            v = vinfo;
  157. X        }
  158. X        vinfo = v;
  159. X    }
  160. X    }
  161. X
  162. X    if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
  163. X    vinfo->class == GrayScale)
  164. X    status = readwrite_map(dpy, vinfo, colormap);
  165. X    else if (vinfo->class == TrueColor)
  166. X    status = TRUEMATCH(red_mult, red_max, red_mask) &&
  167. X             TRUEMATCH(green_mult, green_max, green_mask) &&
  168. X         TRUEMATCH(blue_mult, blue_max, blue_mask);
  169. X    else 
  170. X    status = readonly_map(dpy, vinfo, colormap);
  171. X    
  172. X    XFree((char *) vpointer);
  173. X    return status;
  174. X}
  175. X
  176. X/****************************************************************************/
  177. Xstatic Status readwrite_map(dpy, vinfo, colormap)
  178. X    Display        *dpy;
  179. X    XVisualInfo        *vinfo;
  180. X    XStandardColormap    *colormap;
  181. X{
  182. X    register unsigned long i, n;    /* index counters */
  183. X    int            ncolors;    /* number of colors to be defined */
  184. X    int            npixels;    /* number of pixels allocated R/W */
  185. X    int            first_index;    /* first index of pixels to use */
  186. X    int            remainder;    /* first index of remainder */
  187. X    XColor        color;        /* the definition of a color */
  188. X    unsigned long    *pixels;    /* array of colormap pixels */
  189. X    unsigned long    delta;
  190. X
  191. X    
  192. X    /* Determine ncolors, the number of colors to be defined.
  193. X     * Insure that 1 < ncolors <= the colormap size.
  194. X     */
  195. X    if (vinfo->class == DirectColor) {
  196. X    ncolors = colormap->red_max;
  197. X    if (colormap->green_max > ncolors)
  198. X        ncolors = colormap->green_max;
  199. X    if (colormap->blue_max > ncolors)
  200. X        ncolors = colormap->blue_max;
  201. X    ncolors++;
  202. X    delta = lowbit(vinfo->red_mask) +
  203. X            lowbit(vinfo->green_mask) +
  204. X        lowbit(vinfo->blue_mask);
  205. X    } else {
  206. X    ncolors = colormap->red_max * colormap->red_mult +
  207. X          colormap->green_max * colormap->green_mult +
  208. X          colormap->blue_max * colormap->blue_mult + 1;
  209. X    delta = 1;
  210. X    }
  211. X    if (ncolors <= 1 || ncolors > vinfo->colormap_size)    return 0;
  212. X
  213. X    /* Allocate Read/Write as much of the colormap as we can possibly get.
  214. X     * Then insure that the pixels we were allocated are given in 
  215. X     * monotonically increasing order, using a quicksort.  Next, insure
  216. X     * that our allocation includes a subset of contiguous pixels at least
  217. X     * as long as the number of colors to be defined.  Now we know that 
  218. X     * these conditions are met:
  219. X     *    1) There are no free cells in the colormap.
  220. X     *  2) We have a contiguous sequence of pixels, monotonically 
  221. X     *     increasing, of length >= the number of colors requested.
  222. X     *
  223. X     * One cell at a time, we will free, compute the next color value, 
  224. X     * then allocate read only.  This takes a long time.
  225. X     * This is done to insure that cells are allocated read only in the
  226. X     * contiguous order which we prefer.  If the server has a choice of
  227. X     * cells to grant to an allocation request, the server may give us any
  228. X     * cell, so that is why we do these slow gymnastics.
  229. X     */
  230. X
  231. X    if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
  232. X                      sizeof(unsigned long))) == NULL)
  233. X    return 0;
  234. X
  235. X    if ((npixels = ROmap(dpy, colormap->colormap, pixels,
  236. X               vinfo->colormap_size, ncolors)) == 0) {
  237. X    free((char *) pixels);
  238. X    return 0;
  239. X    }
  240. X
  241. X    qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
  242. X
  243. X    if (!contiguous(pixels, npixels, ncolors, delta, &first_index, &remainder))
  244. X    {
  245. X    /* can't find enough contiguous cells, give up */
  246. X    XFreeColors(dpy, colormap->colormap, pixels, npixels,
  247. X            (unsigned long) 0);
  248. X    free((char *) pixels);
  249. X    return 0;
  250. X    }
  251. X    colormap->base_pixel = pixels[first_index];
  252. X
  253. X    /* construct a gray map */
  254. X    if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
  255. X    colormap->blue_mult == 1)
  256. X    for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
  257. X    {
  258. X        color.pixel = n;
  259. X        color.blue = color.green = color.red =
  260. X        (unsigned short) ((i * 65535) / (colormap->red_max +
  261. X                         colormap->green_max +
  262. X                         colormap->blue_max));
  263. X
  264. X        if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
  265. X                 first_index + i))
  266. X        return 0;
  267. X    }
  268. X
  269. X    /* construct a red ramp map */
  270. X    else if (colormap->green_max == 0 && colormap->blue_max == 0)
  271. X        for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
  272. X    {
  273. X        color.pixel = n;
  274. X        color.red = (unsigned short) ((i * 65535) / colormap->red_max);
  275. X        color.green = color.blue = 0;
  276. X
  277. X        if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
  278. X                 first_index + i))
  279. X        return 0;
  280. X    }
  281. X
  282. X    /* construct a green ramp map */
  283. X    else if (colormap->red_max == 0 && colormap->blue_max == 0)
  284. X        for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
  285. X    {
  286. X        color.pixel = n;
  287. X        color.green = (unsigned short) ((i * 65535) / colormap->green_max);
  288. X        color.red = color.blue = 0;
  289. X
  290. X        if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
  291. X                 first_index + i))
  292. X        return 0;
  293. X    }
  294. X
  295. X    /* construct a blue ramp map */
  296. X    else if (colormap->red_max == 0 && colormap->green_max == 0)
  297. X        for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
  298. X    {
  299. X        color.pixel = n;
  300. X        color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
  301. X        color.red = color.green = 0;
  302. X
  303. X        if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
  304. X                 first_index + i))
  305. X        return 0;
  306. X    }
  307. X
  308. X    /* construct a standard red green blue cube map */
  309. X    else
  310. X    {
  311. X#define calc(max,mult) (((n / colormap->mult) % \
  312. X             (colormap->max + 1)) * 65535) / colormap->max
  313. X
  314. X        for (n=0, i=0; i < ncolors; i++, n += delta)
  315. X    {
  316. X        color.pixel = n + colormap->base_pixel;
  317. X        color.red = calc(red_max, red_mult);
  318. X        color.green = calc(green_max, green_mult);
  319. X        color.blue = calc(blue_max, blue_mult);
  320. X        if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
  321. X                 first_index + i))
  322. X        return 0;
  323. X    }
  324. X#undef calc
  325. X    }
  326. X    /* We have a read-only map defined.  Now free unused cells,
  327. X     * first those occuring before the contiguous sequence begins,
  328. X     * then any following the contiguous sequence.
  329. X     */
  330. X
  331. X    if (first_index)
  332. X    XFreeColors(dpy, colormap->colormap, pixels, first_index, 
  333. X            (unsigned long) 0);
  334. X    if (remainder)
  335. X    XFreeColors(dpy, colormap->colormap,
  336. X            &(pixels[first_index + ncolors]), remainder,
  337. X            (unsigned long) 0);
  338. X
  339. X    free((char *) pixels);
  340. X    return 1;
  341. X}
  342. X
  343. X
  344. X/****************************************************************************/
  345. Xstatic int ROmap(dpy, cmap, pixels, m, n)
  346. X    Display        *dpy;        /* the X server connection */
  347. X    Colormap        cmap;        /* specifies colormap ID */
  348. X    unsigned long    pixels[];    /* returns pixel allocations */
  349. X    int            m;        /* specifies colormap size */
  350. X    int            n;        /* specifies number of colors */
  351. X{
  352. X    register int    p;
  353. X
  354. X    /* first try to allocate the entire colormap */
  355. X    if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL, 
  356. X             (unsigned) 0, pixels, (unsigned) m))
  357. X    return m;
  358. X
  359. X    /* Allocate all available cells in the colormap, using a binary
  360. X     * algorithm to discover how many cells we can allocate in the colormap.
  361. X     */
  362. X    m--;
  363. X    while (n <= m) {
  364. X    p = n + ((m - n + 1) / 2);
  365. X    if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
  366. X                 (unsigned) 0, pixels, (unsigned) p)) {
  367. X        if (p == m)
  368. X        return p;
  369. X        else {
  370. X        XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
  371. X        n = p;
  372. X        }
  373. X    }
  374. X    else
  375. X        m = p - 1;
  376. X    }
  377. X    return 0;
  378. X}
  379. X      
  380. X
  381. X/****************************************************************************/
  382. Xstatic Status contiguous(pixels, npixels, ncolors, delta, first, rem)
  383. X    unsigned long    pixels[];    /* specifies allocated pixels */
  384. X    int            npixels;    /* specifies count of alloc'd pixels */
  385. X    int            ncolors;    /* specifies needed sequence length */
  386. X    unsigned long    delta;        /* between pixels */
  387. X    int            *first;        /* returns first index of sequence */
  388. X    int            *rem;        /* returns first index after sequence,
  389. X                     * or 0, if none follow */
  390. X{
  391. X    register int i = 1;        /* walking index into the pixel array */
  392. X    register int count = 1;    /* length of sequence discovered so far */
  393. X
  394. X    *first = 0;
  395. X    if (npixels == ncolors) {
  396. X    *rem = 0;
  397. X    return 1;
  398. X    }
  399. X    *rem = npixels - 1;
  400. X    while (count < ncolors && ncolors - count <= *rem)
  401. X    {
  402. X    if (pixels[i-1] + delta == pixels[i])
  403. X        count++;
  404. X    else {
  405. X        count = 1;
  406. X        *first = i;
  407. X    }
  408. X    i++;
  409. X    (*rem)--;
  410. X    }
  411. X    if (count != ncolors)
  412. X    return 0;
  413. X    return 1;
  414. X}
  415. X
  416. X
  417. X/****************************************************************************/
  418. Xstatic Status ROorRWcell(dpy, cmap, pixels, npixels, color, p)
  419. X    Display        *dpy;
  420. X    Colormap        cmap;
  421. X    unsigned long    pixels[];
  422. X    int            npixels;
  423. X    XColor        *color;
  424. X    unsigned long    p;
  425. X{
  426. X    unsigned long    pixel;
  427. X    XColor        request;
  428. X
  429. X    /* Free the read/write allocation of one cell in the colormap.
  430. X     * Request a read only allocation of one cell in the colormap.
  431. X     * If the read only allocation cannot be granted, give up, because
  432. X     * there must be no free cells in the colormap.
  433. X     * If the read only allocation is granted, but gives us a cell which
  434. X     * is not the one that we just freed, it is probably the case that
  435. X     * we are trying allocate White or Black or some other color which
  436. X     * already has a read-only allocation in the map.  So we try to 
  437. X     * allocate the previously freed cell with a read/write allocation,
  438. X     * because we want contiguous cells for image processing algorithms.
  439. X     */
  440. X     
  441. X    pixel = color->pixel;
  442. X    request.red = color->red;
  443. X    request.green = color->green;
  444. X    request.blue = color->blue;
  445. X
  446. X    XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
  447. X    if (! XAllocColor(dpy, cmap, color) 
  448. X    || (color->pixel != pixel &&
  449. X        (!RWcell(dpy, cmap, color, &request, &pixel)))) 
  450. X    {
  451. X    free_cells(dpy, cmap, pixels, npixels, (int)p);
  452. X    return 0;
  453. X    }
  454. X    return 1;
  455. X}
  456. X
  457. X
  458. X/****************************************************************************/
  459. Xstatic void free_cells(dpy, cmap, pixels, npixels,  p)
  460. X    Display        *dpy;
  461. X    Colormap        cmap;
  462. X    unsigned long    pixels[];    /* to be freed */
  463. X    int            npixels;        /* original number allocated */
  464. X    int            p;      
  465. X{
  466. X    /* One of the npixels allocated has already been freed.
  467. X     * p is the index of the freed pixel.
  468. X     * First free the pixels preceeding p, and there are p of them;
  469. X     * then free the pixels following p, there are npixels - p - 1 of them.
  470. X     */
  471. X    XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
  472. X    XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
  473. X    free((char *) pixels);
  474. X}
  475. X
  476. X
  477. X/****************************************************************************/
  478. Xstatic Status RWcell(dpy, cmap, color, request, pixel)
  479. X    Display        *dpy;
  480. X    Colormap        cmap;
  481. X    XColor        *color;
  482. X    XColor        *request;
  483. X    unsigned long    *pixel;
  484. X{
  485. X    unsigned long    n = *pixel;
  486. X
  487. X    XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0);
  488. X    if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
  489. X               (unsigned) 0, pixel, (unsigned) 1))
  490. X    return 0;
  491. X    if (*pixel != n)
  492. X    {
  493. X    XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
  494. X    return 0;
  495. X    }
  496. X    color->pixel = *pixel;
  497. X    color->flags = DoRed | DoGreen | DoBlue;
  498. X    color->red = request->red;
  499. X    color->green = request->green;
  500. X    color->blue = request->blue;
  501. X    XStoreColors(dpy, cmap, color, 1);
  502. X    return 1;
  503. X}
  504. X
  505. X
  506. X/****************************************************************************/
  507. Xstatic int compare(e1, e2)
  508. X    unsigned long    *e1, *e2;
  509. X{
  510. X    if (*e1 < *e2)    return -1;
  511. X    if (*e1 > *e2)    return 1;
  512. X    return 0;
  513. X}
  514. X
  515. X
  516. X/****************************************************************************/
  517. Xstatic Status readonly_map(dpy, vinfo, colormap)
  518. X    Display        *dpy;
  519. X    XVisualInfo        *vinfo;
  520. X    XStandardColormap    *colormap;
  521. X{
  522. X    int            i, last_pixel;
  523. X    XColor        color;
  524. X
  525. X    last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) * 
  526. X    (colormap->blue_max + 1) + colormap->base_pixel - 1;
  527. X
  528. X    for(i=colormap->base_pixel; i <= last_pixel; i++) {
  529. X
  530. X    color.pixel = (unsigned long) i;
  531. X    color.red = (unsigned short)
  532. X        (((i/colormap->red_mult) * 65535) / colormap->red_max);
  533. X
  534. X    if (vinfo->class == StaticColor) {
  535. X        color.green = (unsigned short)
  536. X        ((((i/colormap->green_mult) % (colormap->green_max + 1)) *
  537. X          65535) / colormap->green_max);
  538. X        color.blue = (unsigned short)
  539. X        (((i%colormap->green_mult) * 65535) / colormap->blue_max);
  540. X    }
  541. X    else    /* vinfo->class == GrayScale, old style allocation XXX */
  542. X        color.green = color.blue = color.red;
  543. X
  544. X    XAllocColor(dpy, colormap->colormap, &color);
  545. X    if (color.pixel != (unsigned long) i)
  546. X        return 0;
  547. X    }
  548. X    return 1;
  549. X}
  550. END_OF_FILE
  551.   if test 17396 -ne `wc -c <'XMU/CrCmap.c'`; then
  552.     echo shar: \"'XMU/CrCmap.c'\" unpacked with wrong size!
  553.   fi
  554.   # end of 'XMU/CrCmap.c'
  555. fi
  556. if test -f 'teapotc.3' -a "${1}" != "-c" ; then 
  557.   echo shar: Will not clobber existing file \"'teapotc.3'\"
  558. else
  559.   echo shar: Extracting \"'teapotc.3'\" \(14709 characters\)
  560.   sed "s/^X//" >'teapotc.3' <<'END_OF_FILE'
  561. X{{0,0,-1.975},{0.014531,0.011613,-0.999827}},
  562. X{{0.664723,1.34956,-1.825},{0.435809,0.900039,0}},
  563. X{{0.661041,1.34209,-1.85692},{0.365784,0.755423,-0.543635}},
  564. X{{0.643405,1.30628,-1.88754},{0.184533,0.3811,-0.905931}},
  565. X{{0.601933,1.22208,-1.91552},{0.08733,0.180355,-0.979717}},
  566. X{{0.52674,1.06942,-1.93958},{0.0435014,0.0898399,-0.995006}},
  567. X{{0.407942,0.82823,-1.95838},{0.0210444,0.0434613,-0.998833}},
  568. X{{0.235657,0.478445,-1.97063},{0.00811517,0.0167596,-0.999827}},
  569. X{{0,0,-1.975},{0.0116129,0.0145311,-0.999827}},
  570. X{{0.34758,1.46099,-1.825},{0.22374,0.974649,0}},
  571. X{{0.345655,1.4529,-1.85692},{0.187887,0.818467,-0.542964}},
  572. X{{0.336433,1.41414,-1.88754},{0.0948736,0.413285,-0.905646}},
  573. X{{0.314747,1.32299,-1.91552},{0.0449099,0.195634,-0.979648}},
  574. X{{0.275429,1.15772,-1.93958},{0.022372,0.0974559,-0.994988}},
  575. X{{0.213311,0.896614,-1.95838},{0.010823,0.0471463,-0.998829}},
  576. X{{0.123224,0.517949,-1.97063},{0.00417375,0.0181806,-0.999826}},
  577. X{{0,0,-1.975},{0.00811517,0.0167596,-0.999827}},
  578. X{{0,1.5,-1.825},{0,1,0}},
  579. X{{0,1.49169,-1.85692},{0,0.840039,-0.542525}},
  580. X{{0,1.45189,-1.88754},{0,0.424434,-0.905459}},
  581. X{{0,1.35831,-1.91552},{0,0.200944,-0.979603}},
  582. X{{0,1.18863,-1.93958},{0,0.100104,-0.994977}},
  583. X{{0,0.920554,-1.95838},{0,0.048428,-0.998827}},
  584. X{{0,0.531778,-1.97063},{0,0.018675,-0.999826}},
  585. X{{0,0,-1.975},{0.00417375,0.0181806,-0.999826}}
  586. X};
  587. X
  588. XPEXVertexNormal pt30[] = {
  589. X{{0,1.5,-1.825},{0,1,0}},
  590. X{{0,1.49169,-1.85692},{0,0.840039,-0.542525}},
  591. X{{0,1.45189,-1.88754},{0,0.424434,-0.905459}},
  592. X{{0,1.35831,-1.91552},{0,0.200944,-0.979603}},
  593. X{{0,1.18863,-1.93958},{0,0.100104,-0.994977}},
  594. X{{0,0.920554,-1.95838},{0,0.048428,-0.998827}},
  595. X{{0,0.531778,-1.97063},{0,0.018675,-0.999826}},
  596. X{{0,0,-1.975},{-0.00417347,0.0181807,-0.999826}},
  597. X{{-0.34758,1.46099,-1.825},{-0.22374,0.974649,0}},
  598. X{{-0.345655,1.4529,-1.85692},{-0.187887,0.818467,-0.542964}},
  599. X{{-0.336433,1.41414,-1.88754},{-0.0948736,0.413285,-0.905646}},
  600. X{{-0.314748,1.32299,-1.91552},{-0.0449098,0.195634,-0.979648}},
  601. X{{-0.275429,1.15772,-1.93958},{-0.0223719,0.0974559,-0.994988}},
  602. X{{-0.213311,0.896614,-1.95838},{-0.0108228,0.0471463,-0.998829}},
  603. X{{-0.123224,0.517949,-1.97063},{-0.00417347,0.0181807,-0.999826}},
  604. X{{0,0,-1.975},{0,0.018675,-0.999826}},
  605. X{{-0.664723,1.34956,-1.825},{-0.435809,0.900039,0}},
  606. X{{-0.661041,1.34209,-1.85692},{-0.365784,0.755423,-0.543635}},
  607. X{{-0.643405,1.30628,-1.88754},{-0.184533,0.3811,-0.905931}},
  608. X{{-0.601933,1.22208,-1.91552},{-0.0873301,0.180355,-0.979717}},
  609. X{{-0.52674,1.06942,-1.93958},{-0.0435015,0.0898399,-0.995006}},
  610. X{{-0.407942,0.82823,-1.95838},{-0.0210445,0.0434613,-0.998833}},
  611. X{{-0.235657,0.478445,-1.97063},{-0.00811527,0.0167595,-0.999827}},
  612. X{{0,0,-1.975},{-0.00417347,0.0181807,-0.999826}},
  613. X{{-0.943032,1.17411,-1.825},{-0.624305,0.781181,0}},
  614. X{{-0.937808,1.16761,-1.85692},{-0.52383,0.655459,-0.544037}},
  615. X{{-0.912789,1.13646,-1.88754},{-0.264119,0.330487,-0.906101}},
  616. X{{-0.853953,1.0632,-1.91552},{-0.124976,0.15638,-0.979758}},
  617. X{{-0.747277,0.930389,-1.93958},{-0.0622519,0.0778947,-0.995016}},
  618. X{{-0.578741,0.720555,-1.95838},{-0.030115,0.0376823,-0.998836}},
  619. X{{-0.334323,0.416244,-1.97063},{-0.011613,0.014531,-0.999827}},
  620. X{{0,0,-1.975},{-0.00811527,0.0167595,-0.999827}},
  621. X{{-1.17411,0.943032,-1.825},{-0.781181,0.624304,0}},
  622. X{{-1.16761,0.937808,-1.85692},{-0.655459,0.52383,-0.544037}},
  623. X{{-1.13646,0.912789,-1.88754},{-0.330488,0.264119,-0.906101}},
  624. X{{-1.0632,0.853953,-1.91552},{-0.15638,0.124976,-0.979758}},
  625. X{{-0.930389,0.747277,-1.93958},{-0.0778947,0.0622519,-0.995016}},
  626. X{{-0.720555,0.578741,-1.95838},{-0.0376823,0.030115,-0.998836}},
  627. X{{-0.416244,0.334323,-1.97063},{-0.0145311,0.0116129,-0.999827}},
  628. X{{0,0,-1.975},{-0.011613,0.014531,-0.999827}},
  629. X{{-1.34956,0.664723,-1.825},{-0.900039,0.435809,0}},
  630. X{{-1.34209,0.661041,-1.85692},{-0.755423,0.365784,-0.543635}},
  631. X{{-1.30628,0.643405,-1.88754},{-0.3811,0.184533,-0.905931}},
  632. X{{-1.22208,0.601933,-1.91552},{-0.180355,0.08733,-0.979717}},
  633. X{{-1.06942,0.52674,-1.93958},{-0.0898399,0.0435014,-0.995006}},
  634. X{{-0.82823,0.407942,-1.95838},{-0.0434613,0.0210444,-0.998833}},
  635. X{{-0.478445,0.235657,-1.97063},{-0.0167596,0.00811517,-0.999827}},
  636. X{{0,0,-1.975},{-0.0145311,0.0116129,-0.999827}},
  637. X{{-1.46099,0.34758,-1.825},{-0.974649,0.22374,0}},
  638. X{{-1.4529,0.345655,-1.85692},{-0.818467,0.187887,-0.542964}},
  639. X{{-1.41414,0.336433,-1.88754},{-0.413285,0.0948736,-0.905646}},
  640. X{{-1.32299,0.314747,-1.91552},{-0.195634,0.0449099,-0.979648}},
  641. X{{-1.15772,0.275429,-1.93958},{-0.0974559,0.022372,-0.994988}},
  642. X{{-0.896614,0.213311,-1.95838},{-0.0471463,0.010823,-0.998829}},
  643. X{{-0.517949,0.123224,-1.97063},{-0.0181806,0.00417375,-0.999826}},
  644. X{{0,0,-1.975},{-0.0167596,0.00811517,-0.999827}},
  645. X{{-1.5,0,-1.825},{-1,0,0}},
  646. X{{-1.49169,0,-1.85692},{-0.840039,0,-0.542525}},
  647. X{{-1.45189,0,-1.88754},{-0.424434,0,-0.905459}},
  648. X{{-1.35831,0,-1.91552},{-0.200944,0,-0.979603}},
  649. X{{-1.18863,0,-1.93958},{-0.100104,0,-0.994977}},
  650. X{{-0.920554,0,-1.95838},{-0.048428,0,-0.998827}},
  651. X{{-0.531778,0,-1.97063},{-0.018675,0,-0.999826}},
  652. X{{0,0,-1.975},{-0.0181806,0.00417375,-0.999826}}
  653. X};
  654. X
  655. XPEXVertexNormal pt31[] = {
  656. X{{-1.5,0,-1.825},{-1,0,0}},
  657. X{{-1.49169,0,-1.85692},{-0.840039,0,-0.542525}},
  658. X{{-1.45189,0,-1.88754},{-0.424434,0,-0.905459}},
  659. X{{-1.35831,0,-1.91552},{-0.200944,0,-0.979603}},
  660. X{{-1.18863,0,-1.93958},{-0.100104,0,-0.994977}},
  661. X{{-0.920554,0,-1.95838},{-0.048428,0,-0.998827}},
  662. X{{-0.531778,0,-1.97063},{-0.018675,0,-0.999826}},
  663. X{{0,0,-1.975},{-0.0181807,-0.00417347,-0.999826}},
  664. X{{-1.46099,-0.34758,-1.825},{-0.974649,-0.22374,0}},
  665. X{{-1.4529,-0.345655,-1.85692},{-0.818467,-0.187887,-0.542964}},
  666. X{{-1.41414,-0.336433,-1.88754},{-0.413285,-0.0948736,-0.905646}},
  667. X{{-1.32299,-0.314748,-1.91552},{-0.195634,-0.0449098,-0.979648}},
  668. X{{-1.15772,-0.275429,-1.93958},{-0.0974559,-0.0223719,-0.994988}},
  669. X{{-0.896614,-0.213311,-1.95838},{-0.0471463,-0.0108228,-0.998829}},
  670. X{{-0.517949,-0.123224,-1.97063},{-0.0181807,-0.00417347,-0.999826}},
  671. X{{0,0,-1.975},{-0.018675,0,-0.999826}},
  672. X{{-1.34956,-0.664723,-1.825},{-0.900039,-0.435809,0}},
  673. X{{-1.34209,-0.661041,-1.85692},{-0.755423,-0.365784,-0.543635}},
  674. X{{-1.30628,-0.643405,-1.88754},{-0.3811,-0.184533,-0.905931}},
  675. X{{-1.22208,-0.601933,-1.91552},{-0.180355,-0.0873301,-0.979717}},
  676. X{{-1.06942,-0.52674,-1.93958},{-0.0898399,-0.0435015,-0.995006}},
  677. X{{-0.82823,-0.407942,-1.95838},{-0.0434613,-0.0210445,-0.998833}},
  678. X{{-0.478445,-0.235657,-1.97063},{-0.0167595,-0.00811527,-0.999827}},
  679. X{{0,0,-1.975},{-0.0181807,-0.00417347,-0.999826}},
  680. X{{-1.17411,-0.943032,-1.825},{-0.781181,-0.624305,0}},
  681. X{{-1.16761,-0.937808,-1.85692},{-0.655459,-0.52383,-0.544037}},
  682. X{{-1.13646,-0.912789,-1.88754},{-0.330487,-0.264119,-0.906101}},
  683. X{{-1.0632,-0.853953,-1.91552},{-0.15638,-0.124976,-0.979758}},
  684. X{{-0.930389,-0.747277,-1.93958},{-0.0778947,-0.0622519,-0.995016}},
  685. X{{-0.720555,-0.578741,-1.95838},{-0.0376823,-0.030115,-0.998836}},
  686. X{{-0.416244,-0.334323,-1.97063},{-0.014531,-0.011613,-0.999827}},
  687. X{{0,0,-1.975},{-0.0167595,-0.00811527,-0.999827}},
  688. X{{-0.943032,-1.17411,-1.825},{-0.624304,-0.781181,0}},
  689. X{{-0.937808,-1.16761,-1.85692},{-0.52383,-0.655459,-0.544037}},
  690. X{{-0.912789,-1.13646,-1.88754},{-0.264119,-0.330488,-0.906101}},
  691. X{{-0.853953,-1.0632,-1.91552},{-0.124976,-0.15638,-0.979758}},
  692. X{{-0.747277,-0.930389,-1.93958},{-0.0622519,-0.0778947,-0.995016}},
  693. X{{-0.578741,-0.720555,-1.95838},{-0.030115,-0.0376823,-0.998836}},
  694. X{{-0.334323,-0.416244,-1.97063},{-0.0116129,-0.0145311,-0.999827}},
  695. X{{0,0,-1.975},{-0.014531,-0.011613,-0.999827}},
  696. X{{-0.664723,-1.34956,-1.825},{-0.435809,-0.900039,0}},
  697. X{{-0.661041,-1.34209,-1.85692},{-0.365784,-0.755423,-0.543635}},
  698. X{{-0.643405,-1.30628,-1.88754},{-0.184533,-0.3811,-0.905931}},
  699. X{{-0.601933,-1.22208,-1.91552},{-0.08733,-0.180355,-0.979717}},
  700. X{{-0.52674,-1.06942,-1.93958},{-0.0435014,-0.0898399,-0.995006}},
  701. X{{-0.407942,-0.82823,-1.95838},{-0.0210444,-0.0434613,-0.998833}},
  702. X{{-0.235657,-0.478445,-1.97063},{-0.00811517,-0.0167596,-0.999827}},
  703. X{{0,0,-1.975},{-0.0116129,-0.0145311,-0.999827}},
  704. X{{-0.34758,-1.46099,-1.825},{-0.22374,-0.974649,0}},
  705. X{{-0.345655,-1.4529,-1.85692},{-0.187887,-0.818467,-0.542964}},
  706. X{{-0.336433,-1.41414,-1.88754},{-0.0948736,-0.413285,-0.905646}},
  707. X{{-0.314747,-1.32299,-1.91552},{-0.0449099,-0.195634,-0.979648}},
  708. X{{-0.275429,-1.15772,-1.93958},{-0.022372,-0.0974559,-0.994988}},
  709. X{{-0.213311,-0.896614,-1.95838},{-0.010823,-0.0471463,-0.998829}},
  710. X{{-0.123224,-0.517949,-1.97063},{-0.00417375,-0.0181806,-0.999826}},
  711. X{{0,0,-1.975},{-0.00811517,-0.0167596,-0.999827}},
  712. X{{0,-1.5,-1.825},{0,-1,0}},
  713. X{{0,-1.49169,-1.85692},{0,-0.840039,-0.542525}},
  714. X{{0,-1.45189,-1.88754},{0,-0.424434,-0.905459}},
  715. X{{0,-1.35831,-1.91552},{0,-0.200944,-0.979603}},
  716. X{{0,-1.18863,-1.93958},{0,-0.100104,-0.994977}},
  717. X{{0,-0.920554,-1.95838},{0,-0.048428,-0.998827}},
  718. X{{0,-0.531778,-1.97063},{0,-0.018675,-0.999826}},
  719. X{{0,0,-1.975},{-0.00417375,-0.0181806,-0.999826}}
  720. X};
  721. X
  722. XPEXVertexNormal pt32[] = {
  723. X{{0,-1.5,-1.825},{0,-1,0}},
  724. X{{0,-1.49169,-1.85692},{0,-0.840039,-0.542525}},
  725. X{{0,-1.45189,-1.88754},{0,-0.424434,-0.905459}},
  726. X{{0,-1.35831,-1.91552},{0,-0.200944,-0.979603}},
  727. X{{0,-1.18863,-1.93958},{0,-0.100104,-0.994977}},
  728. X{{0,-0.920554,-1.95838},{0,-0.048428,-0.998827}},
  729. X{{0,-0.531778,-1.97063},{0,-0.018675,-0.999826}},
  730. X{{0,0,-1.975},{0.00417347,-0.0181807,-0.999826}},
  731. X{{0.34758,-1.46099,-1.825},{0.22374,-0.974649,0}},
  732. X{{0.345655,-1.4529,-1.85692},{0.187887,-0.818467,-0.542964}},
  733. X{{0.336433,-1.41414,-1.88754},{0.0948736,-0.413285,-0.905646}},
  734. X{{0.314748,-1.32299,-1.91552},{0.0449098,-0.195634,-0.979648}},
  735. X{{0.275429,-1.15772,-1.93958},{0.0223719,-0.0974559,-0.994988}},
  736. X{{0.213311,-0.896614,-1.95838},{0.0108228,-0.0471463,-0.998829}},
  737. X{{0.123224,-0.517949,-1.97063},{0.00417347,-0.0181807,-0.999826}},
  738. X{{0,0,-1.975},{0,-0.018675,-0.999826}},
  739. X{{0.664723,-1.34956,-1.825},{0.435809,-0.900039,0}},
  740. X{{0.661041,-1.34209,-1.85692},{0.365784,-0.755423,-0.543635}},
  741. X{{0.643405,-1.30628,-1.88754},{0.184533,-0.3811,-0.905931}},
  742. X{{0.601933,-1.22208,-1.91552},{0.0873301,-0.180355,-0.979717}},
  743. X{{0.52674,-1.06942,-1.93958},{0.0435015,-0.0898399,-0.995006}},
  744. X{{0.407942,-0.82823,-1.95838},{0.0210445,-0.0434613,-0.998833}},
  745. X{{0.235657,-0.478445,-1.97063},{0.00811527,-0.0167595,-0.999827}},
  746. X{{0,0,-1.975},{0.00417347,-0.0181807,-0.999826}},
  747. X{{0.943032,-1.17411,-1.825},{0.624305,-0.781181,0}},
  748. X{{0.937808,-1.16761,-1.85692},{0.52383,-0.655459,-0.544037}},
  749. X{{0.912789,-1.13646,-1.88754},{0.264119,-0.330487,-0.906101}},
  750. X{{0.853953,-1.0632,-1.91552},{0.124976,-0.15638,-0.979758}},
  751. X{{0.747277,-0.930389,-1.93958},{0.0622519,-0.0778947,-0.995016}},
  752. X{{0.578741,-0.720555,-1.95838},{0.030115,-0.0376823,-0.998836}},
  753. X{{0.334323,-0.416244,-1.97063},{0.011613,-0.014531,-0.999827}},
  754. X{{0,0,-1.975},{0.00811527,-0.0167595,-0.999827}},
  755. X{{1.17411,-0.943032,-1.825},{0.781181,-0.624304,0}},
  756. X{{1.16761,-0.937808,-1.85692},{0.655459,-0.52383,-0.544037}},
  757. X{{1.13646,-0.912789,-1.88754},{0.330488,-0.264119,-0.906101}},
  758. X{{1.0632,-0.853953,-1.91552},{0.15638,-0.124976,-0.979758}},
  759. X{{0.930389,-0.747277,-1.93958},{0.0778947,-0.0622519,-0.995016}},
  760. X{{0.720555,-0.578741,-1.95838},{0.0376823,-0.030115,-0.998836}},
  761. X{{0.416244,-0.334323,-1.97063},{0.0145311,-0.0116129,-0.999827}},
  762. X{{0,0,-1.975},{0.011613,-0.014531,-0.999827}},
  763. X{{1.34956,-0.664723,-1.825},{0.900039,-0.435809,0}},
  764. X{{1.34209,-0.661041,-1.85692},{0.755423,-0.365784,-0.543635}},
  765. X{{1.30628,-0.643405,-1.88754},{0.3811,-0.184533,-0.905931}},
  766. X{{1.22208,-0.601933,-1.91552},{0.180355,-0.08733,-0.979717}},
  767. X{{1.06942,-0.52674,-1.93958},{0.0898399,-0.0435014,-0.995006}},
  768. X{{0.82823,-0.407942,-1.95838},{0.0434613,-0.0210444,-0.998833}},
  769. X{{0.478445,-0.235657,-1.97063},{0.0167596,-0.00811517,-0.999827}},
  770. X{{0,0,-1.975},{0.0145311,-0.0116129,-0.999827}},
  771. X{{1.46099,-0.34758,-1.825},{0.974649,-0.22374,0}},
  772. X{{1.4529,-0.345655,-1.85692},{0.818467,-0.187887,-0.542964}},
  773. X{{1.41414,-0.336433,-1.88754},{0.413285,-0.0948736,-0.905646}},
  774. X{{1.32299,-0.314747,-1.91552},{0.195634,-0.0449099,-0.979648}},
  775. X{{1.15772,-0.275429,-1.93958},{0.0974559,-0.022372,-0.994988}},
  776. X{{0.896614,-0.213311,-1.95838},{0.0471463,-0.010823,-0.998829}},
  777. X{{0.517949,-0.123224,-1.97063},{0.0181806,-0.00417375,-0.999826}},
  778. X{{0,0,-1.975},{0.0167596,-0.00811517,-0.999827}},
  779. X{{1.5,0,-1.825},{1,0,0}},
  780. X{{1.49169,0,-1.85692},{0.840039,0,-0.542525}},
  781. X{{1.45189,0,-1.88754},{0.424434,0,-0.905459}},
  782. X{{1.35831,0,-1.91552},{0.200944,0,-0.979603}},
  783. X{{1.18863,0,-1.93958},{0.100104,0,-0.994977}},
  784. X{{0.920554,0,-1.95838},{0.048428,0,-0.998827}},
  785. X{{0.531778,0,-1.97063},{0.018675,0,-0.999826}},
  786. X{{0,0,-1.975},{0.0181806,-0.00417375,-0.999826}}
  787. X};
  788. X
  789. XPEXVertexNormal *ptrs[] = {pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,
  790. X  pt9,pt10,pt11,pt12,pt13,pt14,pt15,pt16,
  791. X  pt17,pt18,pt19,pt20,pt21,pt22,pt23,pt24,
  792. X  pt25,pt26,pt27,pt28,pt29,pt30,pt31,pt32};
  793. X
  794. XPEXColorRGB myColor = { 1.0, 0., 0.8};
  795. Xmain (argc, argv)
  796. X     int argc;
  797. X     char  *argv[];
  798. X{
  799. X  Display        *theDisplay;
  800. X  char            *displayString = (char *)0;
  801. X  PEXExtensionInfo    *info_return;
  802. X  char            err_msg[PEXErrorStringLength];
  803. X  XID                   theStrux;  
  804. X  int                   i, j;
  805. X  PEXCoord p[2];
  806. X  PEXArrayOfVertex      vdata;
  807. X  PEXArrayOfFacetData      aFacetData;
  808. X  PEXVector             fnorm[100];
  809. X
  810. X  for ( i = 1; i<argc; i++ ) {
  811. X    if ((strncmp(argv[i],"-display",strlen(argv[i]))) == 0) {
  812. X      if (++i > argc) { printf("not enough args"); exit(1); }
  813. X      displayString = argv[i];
  814. X    } else if ((strncmp(argv[i],"-strux",strlen(argv[i]))) == 0) {
  815. X      if (++i > argc) { printf("not enough args"); exit(1); }
  816. X      theStrux = atoi(argv[i]);
  817. X    }
  818. X  }
  819. X
  820. X  /*
  821. X   * Open the display and initialize the PEX extension.
  822. X   */
  823. X  
  824. X  if (!(theDisplay = XOpenDisplay(displayString)))
  825. X    {
  826. X      printf ( "Could not open display %s\n",displayString);
  827. X      exit (1);
  828. X    }
  829. X  
  830. X  if (PEXInitialize(theDisplay, &info_return, PEXErrorStringLength, err_msg))
  831. X    {
  832. X      printf ("%s\n", err_msg);
  833. X      exit (1);        
  834. X    }
  835. X
  836. X  PEXSetLineColorIndex( theDisplay, theStrux, PEXOCStore, 2);
  837. X  p[0].x = 0; p[0].y = 0; p[0].z = 0;
  838. X  p[1].x = -2; p[1].y = -2; p[1].z = -2;
  839. X  PEXPolyline(theDisplay, theStrux, PEXOCStore, 2, p );
  840. X
  841. X  PEXSetSurfaceColor( theDisplay, theStrux, PEXOCStore, PEXColorTypeRGB, 
  842. X             (PEXColor *)&myColor);
  843. X
  844. X  aFacetData.normal = fnorm;
  845. X
  846. X  for ( i = 0; i < 32; i++ ) {
  847. X    vdata.normal = ptrs[i];
  848. X
  849. X
  850. X    PEXGeoNormQuadrilateralMesh( PEXGANormal, PEXGANormal,
  851. X                PEXColorTypeRGB, aFacetData, 8, 8, vdata );
  852. X
  853. X    for (j = 0; j < 49; j++ ) {
  854. X      fnorm[j].x = -fnorm[j].x;
  855. X      fnorm[j].y = -fnorm[j].y;
  856. X      fnorm[j].z = -fnorm[j].z;
  857. X    }
  858. X
  859. X    PEXSetSurfaceColor( theDisplay, theStrux, PEXOCStore, PEXColorTypeRGB, 
  860. X               (PEXColor *)&myColor);
  861. X
  862. X    PEXQuadrilateralMesh(theDisplay, theStrux, PEXOCStore,
  863. X             PEXShapeConvex, PEXGANormal, PEXGANormal,
  864. X             PEXColorTypeRGB, aFacetData, 8, 8, vdata );
  865. X  }
  866. X
  867. X  XSync(theDisplay,0);
  868. X}
  869. END_OF_FILE
  870.   if test 14709 -ne `wc -c <'teapotc.3'`; then
  871.     echo shar: \"'teapotc.3'\" unpacked with wrong size!
  872.   fi
  873.   # end of 'teapotc.3'
  874. fi
  875. if test -f 'util/pexutdbint.c' -a "${1}" != "-c" ; then 
  876.   echo shar: Will not clobber existing file \"'util/pexutdbint.c'\"
  877. else
  878.   echo shar: Extracting \"'util/pexutdbint.c'\" \(6265 characters\)
  879.   sed "s/^X//" >'util/pexutdbint.c' <<'END_OF_FILE'
  880. X/* $Header: pexutdbint.c,v 500.1.200.1 93/03/17 13:50:54 rj Exp $ */
  881. X
  882. X/******************************************************************************/
  883. X/*  (c) Copyright Hewlett-Packard Company, 1992,  Fort Collins, Colorado      */
  884. X/*                                                                            */
  885. X/*                            All Rights Reserved                             */
  886. X/*                                                                            */
  887. X/*  Permission to use, copy, modify, and distribute this software and its     */
  888. X/*  documentation for any purpose and without fee is hereby granted provided  */
  889. X/*  that the above copyright notices appear in all copies and that both the   */
  890. X/*  copyright notices and this permission notice appear in supporting         */
  891. X/*  documentation, and that the name of Hewlett-Packard not be used in        */
  892. X/*  advertising or publicity pertaining to distribution of the software       */
  893. X/*  without specific, written prior permission.                               */
  894. X/*                                                                            */
  895. X/*  HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS         */
  896. X/*  SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
  897. X/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Hewlett-Packard    */
  898. X/*  shall not be liable for errors contained herein or direct, indirect,      */
  899. X/*  special, incidental or consequential damages in connection with the       */
  900. X/*  furnishing, performance or use of this software.                          */
  901. X/*                                                                            */
  902. X/******************************************************************************/
  903. X
  904. X/******************************************************************************/
  905. X/*                                                                            */
  906. X/* Module:  PEXlib Double-Buffer Utilities                                    */
  907. X/*                                                                            */
  908. X/* File Content:                                                              */
  909. X/*   This file contains source code for data management functions used by the */
  910. X/*   PEXlib double-buffer utilities.                                          */
  911. X/*                                                                            */
  912. X/******************************************************************************/
  913. X
  914. X
  915. X/*
  916. X** Include files
  917. X*/
  918. X#include <X11/PEX5/PEXlib.h>
  919. X#include "pexutdbint.h"
  920. X
  921. X
  922. X/*
  923. X** Global internal data
  924. X*/
  925. Xstatic PEXUtDBData *pexutdb_head = (PEXUtDBData *)NULL;   /* modified by all  */
  926. X                                                          /* *_node functions */
  927. X
  928. X
  929. X
  930. X/******************************************************************************/
  931. X/*                                                                            */
  932. X/* lookup_node                                                                */
  933. X/*                                                                            */
  934. X/******************************************************************************/
  935. X
  936. XPEXUtDBData *lookup_node( win, dpy )
  937. X    Window      win;
  938. X    Display     *dpy;
  939. X{
  940. X    PEXUtDBData *ptr;
  941. X    
  942. X    ptr = pexutdb_head;
  943. X    while ( ptr != (PEXUtDBData *)NULL ) {
  944. X        if ( ( ptr->window != win ) || ( ptr->display != dpy ) )
  945. X            ptr = ptr->next;
  946. X        else
  947. X            break;
  948. X    }
  949. X
  950. X    return( ptr );
  951. X}
  952. X
  953. X
  954. X
  955. X/******************************************************************************/
  956. X/*                                                                            */
  957. X/* add_node                                                                   */
  958. X/*                                                                            */
  959. X/******************************************************************************/
  960. X
  961. XPEXUtDBData *add_node( win, dpy )
  962. X    Window      win;
  963. X    Display     *dpy;
  964. X{
  965. X    PEXUtDBData *ptr;
  966. X    
  967. X    if ( pexutdb_head == (PEXUtDBData *)NULL ) {
  968. X        /*
  969. X        ** if no data, create a new list of nodes
  970. X        */
  971. X        ptr = (PEXUtDBData *)malloc( sizeof( PEXUtDBData ) );
  972. X        if ( ptr == (PEXUtDBData *)NULL )
  973. X            return( ptr );
  974. X        ptr->next = (PEXUtDBData *)NULL;
  975. X    } else {
  976. X        /*
  977. X        ** check for existing node with matching search keys
  978. X        */
  979. X        ptr = pexutdb_head;
  980. X        while ( ptr != (PEXUtDBData *)NULL ) {
  981. X            if ( ( ptr->window == win ) && ( ptr->display == dpy ) )
  982. X                return( (PEXUtDBData *)NULL );
  983. X            ptr = ptr->next;
  984. X        }
  985. X        /*
  986. X        ** allocate new node
  987. X        */
  988. X        ptr = (PEXUtDBData *)malloc( sizeof( PEXUtDBData ) );
  989. X        if ( ptr == (PEXUtDBData *)NULL )
  990. X            return( ptr );
  991. X        /*
  992. X        ** add the new data node at the beginning of the list;
  993. X        ** this optimizes searches for the most recent additions
  994. X        */
  995. X        ptr->next = pexutdb_head;
  996. X    }
  997. X
  998. X    pexutdb_head = ptr;
  999. X    return( ptr );
  1000. X}
  1001. X
  1002. X
  1003. X
  1004. X/******************************************************************************/
  1005. X/*                                                                            */
  1006. X/* delete_node                                                                */
  1007. X/*                                                                            */
  1008. X/******************************************************************************/
  1009. X
  1010. Xvoid delete_node( win, dpy )
  1011. X    Window      win;
  1012. X    Display     *dpy;
  1013. X{
  1014. X    PEXUtDBData *ptr, *prev;
  1015. X
  1016. X    if ( pexutdb_head == (PEXUtDBData *)NULL )
  1017. X        return;
  1018. X        
  1019. X    /*
  1020. X    ** first, need to find the previous node
  1021. X    */
  1022. X    ptr = pexutdb_head;
  1023. X    prev = pexutdb_head;
  1024. X    while ( ptr != (PEXUtDBData *)NULL ) {
  1025. X        if ( ( ptr->window != win ) || ( ptr->display != dpy ) ) {
  1026. X            prev = ptr;
  1027. X            ptr = ptr->next;
  1028. X        } else
  1029. X            break;
  1030. X    }
  1031. X
  1032. X    /*
  1033. X    ** now, we have the previous node;
  1034. X    ** point the previous node to the node after the node we are deleting
  1035. X    */
  1036. X    if ( ptr == pexutdb_head )
  1037. X        pexutdb_head = ptr->next;
  1038. X    else
  1039. X        prev->next = ptr->next;
  1040. X        
  1041. X    /*
  1042. X    ** now, free the node
  1043. X    */
  1044. X    free( ptr );
  1045. X}
  1046. END_OF_FILE
  1047.   if test 6265 -ne `wc -c <'util/pexutdbint.c'`; then
  1048.     echo shar: \"'util/pexutdbint.c'\" unpacked with wrong size!
  1049.   fi
  1050.   # end of 'util/pexutdbint.c'
  1051. fi
  1052. if test -f 'util/pexutdbint.h' -a "${1}" != "-c" ; then 
  1053.   echo shar: Will not clobber existing file \"'util/pexutdbint.h'\"
  1054. else
  1055.   echo shar: Extracting \"'util/pexutdbint.h'\" \(17902 characters\)
  1056.   sed "s/^X//" >'util/pexutdbint.h' <<'END_OF_FILE'
  1057. X/* $Header: pexutdbint.h,v 500.1.200.1 93/03/17 14:14:40 rj Exp $ */
  1058. X
  1059. X/******************************************************************************/
  1060. X/*  (c) Copyright Hewlett-Packard Company, 1992,  Fort Collins, Colorado      */
  1061. X/*                                                                            */
  1062. X/*                            All Rights Reserved                             */
  1063. X/*                                                                            */
  1064. X/*  Permission to use, copy, modify, and distribute this software and its     */
  1065. X/*  documentation for any purpose and without fee is hereby granted provided  */
  1066. X/*  that the above copyright notices appear in all copies and that both the   */
  1067. X/*  copyright notices and this permission notice appear in supporting         */
  1068. X/*  documentation, and that the name of Hewlett-Packard not be used in        */
  1069. X/*  advertising or publicity pertaining to distribution of the software       */
  1070. X/*  without specific, written prior permission.                               */
  1071. X/*                                                                            */
  1072. X/*  HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS         */
  1073. X/*  SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
  1074. X/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Hewlett-Packard    */
  1075. X/*  shall not be liable for errors contained herein or direct, indirect,      */
  1076. X/*  special, incidental or consequential damages in connection with the       */
  1077. X/*  furnishing, performance or use of this software.                          */
  1078. X/*                                                                            */
  1079. X/******************************************************************************/
  1080. X
  1081. X/******************************************************************************/
  1082. X/*                                                                            */
  1083. X/* Module:  PEXlib Double-Buffer Utilities (see file pexutdb.h for more info) */
  1084. X/*                                                                            */
  1085. X/* File Content:                                                              */
  1086. X/*   This file contains constants, data structures and function declarations  */
  1087. X/*   for internal use in the PEXlib double-buffer utilities.                  */
  1088. X/*                                                                            */
  1089. X/******************************************************************************/
  1090. X
  1091. X
  1092. X#ifndef _PEXUTDBINT_H_ /* [ */
  1093. X#define _PEXUTDBINT_H_
  1094. X
  1095. X
  1096. X#ifndef NeedFunctionPrototypes
  1097. X#if defined(FUNCPROTO) || defined(__STDC__) || \
  1098. X    defined(__cplusplus) || defined(c_plusplus)
  1099. X#define NeedFunctionPrototypes  1
  1100. X#else
  1101. X#define NeedFunctionPrototypes  0
  1102. X#endif /* FUNCPROTO, __STDC__, __cplusplus, c_plusplus */
  1103. X#endif /* NeedFunctionPrototypes */
  1104. X
  1105. X
  1106. X#ifdef __cplusplus   /* do not leave open across includes */
  1107. Xextern "C" {         /* for C++ V2.0 */
  1108. X#endif
  1109. X
  1110. X
  1111. X/*
  1112. X** Data structures and constants for the Multi-Buffering Extension (MBX).
  1113. X** This is included here because some vendors ship the MBX library extension,
  1114. X** but not the multibuf.h include file.
  1115. X** This is the X11R5 version of the multibuf.h include file.
  1116. X*/
  1117. X
  1118. X/*
  1119. X * $XConsortium: multibuf.h,v 1.15 91/07/12 10:20:42 rws Exp $
  1120. X *
  1121. X * Copyright 1989 Massachusetts Institute of Technology
  1122. X *
  1123. X * Permission to use, copy, modify, distribute, and sell this software and its
  1124. X * documentation for any purpose is hereby granted without fee, provided that
  1125. X * the above copyright notice appear in all copies and that both that
  1126. X * copyright notice and this permission notice appear in supporting
  1127. X * documentation, and that the name of M.I.T. not be used in advertising or
  1128. X * publicity pertaining to distribution of the software without specific,
  1129. X * written prior permission.  M.I.T. makes no representations about the
  1130. X * suitability of this software for any purpose.  It is provided "as is"
  1131. X * without express or implied warranty.
  1132. X *
  1133. X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  1134. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  1135. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1136. X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  1137. X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  1138. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1139. X */
  1140. X
  1141. X#ifndef _MULTIBUF_H_ /* [ */
  1142. X#define _MULTIBUF_H_
  1143. X
  1144. X#include <X11/Xfuncproto.h>
  1145. X
  1146. X#define MULTIBUFFER_PROTOCOL_NAME "Multi-Buffering"
  1147. X
  1148. X#define MULTIBUFFER_MAJOR_VERSION    1    /* current version numbers */
  1149. X#define MULTIBUFFER_MINOR_VERSION    0
  1150. X
  1151. X#define X_MbufGetBufferVersion        0
  1152. X#define X_MbufCreateImageBuffers    1
  1153. X#define X_MbufDestroyImageBuffers    2
  1154. X#define X_MbufDisplayImageBuffers    3
  1155. X#define X_MbufSetMBufferAttributes    4
  1156. X#define X_MbufGetMBufferAttributes    5
  1157. X#define X_MbufSetBufferAttributes    6
  1158. X#define X_MbufGetBufferAttributes    7
  1159. X#define X_MbufGetBufferInfo        8
  1160. X#define X_MbufCreateStereoWindow    9
  1161. X
  1162. X/*
  1163. X * update_action field
  1164. X */
  1165. X#define MultibufferUpdateActionUndefined    0
  1166. X#define MultibufferUpdateActionBackground    1
  1167. X#define MultibufferUpdateActionUntouched    2
  1168. X#define MultibufferUpdateActionCopied        3
  1169. X
  1170. X/*
  1171. X * update_hint field
  1172. X */
  1173. X#define MultibufferUpdateHintFrequent        0
  1174. X#define MultibufferUpdateHintIntermittent    1
  1175. X#define MultibufferUpdateHintStatic        2
  1176. X
  1177. X/*
  1178. X * valuemask fields
  1179. X */
  1180. X#define MultibufferWindowUpdateHint    (1L << 0)
  1181. X#define MultibufferBufferEventMask    (1L << 0)
  1182. X
  1183. X/*
  1184. X * mono vs. stereo and left vs. right
  1185. X */
  1186. X#define MultibufferModeMono        0
  1187. X#define MultibufferModeStereo        1
  1188. X#define MultibufferSideMono        0
  1189. X#define MultibufferSideLeft          1
  1190. X#define MultibufferSideRight        2
  1191. X
  1192. X/*
  1193. X * clobber state
  1194. X */
  1195. X#define MultibufferUnclobbered        0
  1196. X#define MultibufferPartiallyClobbered    1
  1197. X#define MultibufferFullyClobbered    2
  1198. X
  1199. X/*
  1200. X * event stuff
  1201. X */
  1202. X#define MultibufferClobberNotifyMask    0x02000000
  1203. X#define MultibufferUpdateNotifyMask    0x04000000
  1204. X
  1205. X#define MultibufferClobberNotify    0
  1206. X#define MultibufferUpdateNotify        1
  1207. X#define MultibufferNumberEvents        (MultibufferUpdateNotify + 1)
  1208. X
  1209. X#define MultibufferBadBuffer        0
  1210. X#define MultibufferNumberErrors        (MultibufferBadBuffer + 1)
  1211. X
  1212. X
  1213. X#ifndef _MULTIBUF_SERVER_ /* [ */
  1214. X/*
  1215. X * Extra definitions that will only be needed in the client
  1216. X */
  1217. Xtypedef XID Multibuffer;
  1218. X
  1219. Xtypedef struct {
  1220. X    int    type;            /* of event */
  1221. X    unsigned long serial;   /* # of last request processed by server */
  1222. X    int send_event;        /* true if this came frome a SendEvent request */
  1223. X    Display *display;        /* Display the event was read from */
  1224. X    Multibuffer buffer;        /* buffer of event */
  1225. X    int    state;            /* see Clobbered constants above */
  1226. X} XmbufClobberNotifyEvent;
  1227. X
  1228. Xtypedef struct {
  1229. X    int    type;            /* of event */
  1230. X    unsigned long serial;   /* # of last request processed by server */
  1231. X    int send_event;        /* true if this came frome a SendEvent request */
  1232. X    Display *display;        /* Display the event was read from */
  1233. X    Multibuffer buffer;        /* buffer of event */
  1234. X} XmbufUpdateNotifyEvent;
  1235. X
  1236. X
  1237. X/*
  1238. X * per-window attributes that can be got
  1239. X */
  1240. Xtypedef struct {
  1241. X    int displayed_index;    /* which buffer is being displayed */
  1242. X    int update_action;        /* Undefined, Background, Untouched, Copied */
  1243. X    int update_hint;        /* Frequent, Intermittent, Static */
  1244. X    int window_mode;        /* Mono, Stereo */
  1245. X    int nbuffers;        /* Number of buffers */
  1246. X    Multibuffer *buffers;    /* Buffers */
  1247. X} XmbufWindowAttributes;
  1248. X
  1249. X/*
  1250. X * per-window attributes that can be set
  1251. X */
  1252. Xtypedef struct {
  1253. X    int update_hint;        /* Frequent, Intermittent, Static */
  1254. X} XmbufSetWindowAttributes;
  1255. X
  1256. X
  1257. X/*
  1258. X * per-buffer attributes that can be got
  1259. X */
  1260. Xtypedef struct {
  1261. X    Window window;        /* which window this belongs to */
  1262. X    unsigned long event_mask;    /* events that have been selected */
  1263. X    int buffer_index;        /* which buffer is this */
  1264. X    int side;            /* Mono, Left, Right */
  1265. X} XmbufBufferAttributes;
  1266. X
  1267. X/*
  1268. X * per-buffer attributes that can be set
  1269. X */
  1270. Xtypedef struct {
  1271. X    unsigned long event_mask;    /* events that have been selected */
  1272. X} XmbufSetBufferAttributes;
  1273. X
  1274. X
  1275. X/*
  1276. X * per-screen buffer info (there will be lists of them)
  1277. X */
  1278. Xtypedef struct {
  1279. X    VisualID visualid;        /* visual usuable at this depth */
  1280. X    int max_buffers;        /* most buffers for this visual */
  1281. X    int depth;            /* depth of buffers to be created */
  1282. X} XmbufBufferInfo;
  1283. X
  1284. X_XFUNCPROTOBEGIN
  1285. X
  1286. Xextern Bool XmbufQueryExtension(
  1287. X#if NeedFunctionPrototypes
  1288. X    Display*        /* dpy */,
  1289. X    int*        /* event_base_return */,
  1290. X    int*        /* error_base_return */
  1291. X#endif
  1292. X);
  1293. X
  1294. Xextern Status XmbufGetVersion(
  1295. X#if NeedFunctionPrototypes
  1296. X    Display*        /* dpy */,
  1297. X    int*        /* major_version_return */,
  1298. X    int*        /* minor_version_return */
  1299. X#endif
  1300. X);
  1301. X
  1302. Xextern int XmbufCreateBuffers(
  1303. X#if NeedFunctionPrototypes
  1304. X    Display*        /* dpy */,
  1305. X    Window        /* w */,
  1306. X    int            /* count */,
  1307. X    int            /* update_action */,
  1308. X    int            /* update_hint */,
  1309. X    Multibuffer*    /* buffers */
  1310. X#endif
  1311. X);
  1312. X
  1313. Xextern void XmbufDestroyBuffers(
  1314. X#if NeedFunctionPrototypes
  1315. X    Display*        /* dpy */,
  1316. X    Window        /* window */
  1317. X#endif
  1318. X);
  1319. X
  1320. Xextern void XmbufDisplayBuffers(
  1321. X#if NeedFunctionPrototypes
  1322. X    Display*        /* dpy */,
  1323. X    int            /* count */,
  1324. X    Multibuffer*    /* buffers */,
  1325. X    int            /* min_delay */,
  1326. X    int            /* max_delay */
  1327. X#endif
  1328. X);
  1329. X
  1330. Xextern Status XmbufGetWindowAttributes(
  1331. X#if NeedFunctionPrototypes
  1332. X    Display*            /* dpy */,
  1333. X    Window            /* w */,
  1334. X    XmbufWindowAttributes*    /* attr */
  1335. X#endif
  1336. X);
  1337. X
  1338. Xextern void XmbufChangeWindowAttributes(
  1339. X#if NeedFunctionPrototypes
  1340. X    Display*            /* dpy */,
  1341. X    Window            /* w */,
  1342. X    unsigned long        /* valuemask */,
  1343. X    XmbufSetWindowAttributes*    /* attr */
  1344. X#endif
  1345. X);
  1346. X
  1347. Xextern Status XmbufGetBufferAttributes(
  1348. X#if NeedFunctionPrototypes
  1349. X    Display*            /* dpy */,
  1350. X    Multibuffer            /* b */,
  1351. X    XmbufBufferAttributes*    /* attr */
  1352. X#endif
  1353. X);
  1354. X
  1355. Xextern void XmbufChangeBufferAttributes(
  1356. X#if NeedFunctionPrototypes
  1357. X    Display*            /* dpy */,
  1358. X    Multibuffer            /* b */,
  1359. X    unsigned long        /* valuemask */,
  1360. X    XmbufSetBufferAttributes*    /* attr */
  1361. X#endif
  1362. X);
  1363. X
  1364. Xextern Status XmbufGetScreenInfo(
  1365. X#if NeedFunctionPrototypes
  1366. X    Display*            /* dpy */,
  1367. X    Drawable            /* d */,
  1368. X    int*            /* nmono_return */,
  1369. X    XmbufBufferInfo**        /* mono_info_return */,
  1370. X    int*            /* nstereo_return */,
  1371. X    XmbufBufferInfo**        /* stereo_info_return */
  1372. X#endif
  1373. X);
  1374. X
  1375. Xextern Window XmbufCreateStereoWindow(
  1376. X#if NeedFunctionPrototypes
  1377. X    Display*            /* dpy */,
  1378. X    Window            /* parent */,
  1379. X    int                /* x */,
  1380. X    int                /* y */,
  1381. X    unsigned int        /* width */,
  1382. X    unsigned int        /* height */,
  1383. X    unsigned int        /* border_width */,
  1384. X    int                /* depth */,
  1385. X    unsigned int        /* class */,
  1386. X    Visual*            /* visual */,
  1387. X    unsigned long        /* valuemask */,
  1388. X    XSetWindowAttributes*    /* attr */,
  1389. X    Multibuffer*        /* leftp */,
  1390. X    Multibuffer*        /* rightp */
  1391. X#endif
  1392. X);
  1393. X
  1394. X_XFUNCPROTOEND
  1395. X
  1396. X#endif /* _MULTIBUF_SERVER_ ] */
  1397. X#endif /* _MULTIBUF_H_ ] */
  1398. X
  1399. X
  1400. X/*
  1401. X** Aliases for DFRONT constants defined in order to match data structure name
  1402. X*/
  1403. X#define HP_ESCAPE_SETRENDERINGBUFFER            0x80070001
  1404. X#define HP_ESCAPE_ET_SETRENDERINGBUFFER         0x8701
  1405. X#define HP_ESCAPE_ETM_SETRENDERINGBUFFER        "HP_ESCAPE_DFRONT"
  1406. X
  1407. X
  1408. X/*
  1409. X** constants for dbtype variable in PEXUtDBData
  1410. X*/
  1411. X#define PEXUTDBMBX      0
  1412. X#define PEXUTDBESC      1
  1413. X#define PEXUTDBPIX      2
  1414. X
  1415. X/*
  1416. X** Global internal data
  1417. X*/
  1418. Xtypedef struct pexutdbdata {
  1419. X    Window              window;         /* window id - also search key        */
  1420. X    Display             *display;       /* display ptr - secondary search key */
  1421. X    struct pexutdbdata  *next;          /* ptr to next node in the data list  */
  1422. X    int                 db_type;        /* indicates db mechanism used        */
  1423. X    int                 front_supported;/* indicates support of render front  */
  1424. X    int                 render_to_front;/* flag indicating front or back      */
  1425. X    int                 db_x;           /* indicates double-buffer X rendering*/
  1426. X    Multibuffer         back_buffer;    /* current back buffer, if MBX        */
  1427. X    Multibuffer         buffers[2];     /* buffer identifiers, if using MBX   */
  1428. X    PEXRenderer         renderer;       /* renderer id, used for clearing     */
  1429. X    int                 clear_renderer; /* flag indicating whether to clear   */
  1430. X    Pixmap              pixmap;         /* pixmap identifier, if using pixmap */
  1431. X    GC                  gc;             /* gc for clearing pixmap             */
  1432. X    int                 width;          /* window width                       */
  1433. X    int                 height;         /* window height                      */
  1434. X    int                 depth;          /* window depth                       */
  1435. X} PEXUtDBData;
  1436. X
  1437. X
  1438. X/******************************************************************************/
  1439. X/*                                                                            */
  1440. X/* Internal Functions Description:                                            */
  1441. X/*   This set of functions provides a simple interface for managing global    */
  1442. X/*   data in the PEXlib double-buffer utilities.                              */
  1443. X/*                                                                            */
  1444. X/* Internal Functions:                                                        */
  1445. X/*   lookup_node  - lookup the data node for the specified window             */
  1446. X/*   add_node     - add a new data node for the specified window              */
  1447. X/*   delete_node  - delete the data node for the specified window             */
  1448. X/*                                                                            */
  1449. X/******************************************************************************/
  1450. X
  1451. X/*
  1452. X** function declarations
  1453. X*/
  1454. X
  1455. X/******************************************************************************/
  1456. X/*                                                                            */
  1457. X/* Function:                                                                  */
  1458. X/*   lookup_node    - lookup the data node for the specified window           */
  1459. X/*                                                                            */
  1460. X/* Returns:                                                                   */
  1461. X/*   PEXUtDBData *  - a pointer to the data node                              */
  1462. X/*                                                                            */
  1463. X/* Arguments:                                                                 */
  1464. X/*   win            - window id search key                                    */
  1465. X/*   dpy            - display ptr secondary search key                        */
  1466. X/*                                                                            */
  1467. X/******************************************************************************/
  1468. Xextern PEXUtDBData *lookup_node(
  1469. X#if NeedFunctionPrototypes
  1470. X    Window              /* win */,
  1471. X    Display *           /* dpy */
  1472. X#endif
  1473. X);
  1474. X
  1475. X/******************************************************************************/
  1476. X/*                                                                            */
  1477. X/* Function:                                                                  */
  1478. X/*   add_node       - add a new data node for the specified window            */
  1479. X/*                                                                            */
  1480. X/* Returns:                                                                   */
  1481. X/*   PEXUtDBData *  - a pointer to the new data node                          */
  1482. X/*                                                                            */
  1483. X/* Arguments:                                                                 */
  1484. X/*   win            - window id search key                                    */
  1485. X/*   dpy            - display ptr secondary search key                        */
  1486. X/*                                                                            */
  1487. X/******************************************************************************/
  1488. Xextern PEXUtDBData *add_node(
  1489. X#if NeedFunctionPrototypes
  1490. X    Window              /* win */,
  1491. X    Display *           /* dpy */
  1492. X#endif
  1493. X);
  1494. X
  1495. X/******************************************************************************/
  1496. X/*                                                                            */
  1497. X/* Function:                                                                  */
  1498. X/*   delete_node    - delete the data node for the specified window           */
  1499. X/*                                                                            */
  1500. X/* Returns:                                                                   */
  1501. X/*   void           - no return value                                         */
  1502. X/*                                                                            */
  1503. X/* Arguments:                                                                 */
  1504. X/*   win            - window id search key                                    */
  1505. X/*   dpy            - display ptr secondary search key                        */
  1506. X/*                                                                            */
  1507. X/******************************************************************************/
  1508. Xextern void delete_node(
  1509. X#if NeedFunctionPrototypes
  1510. X    Window              /* win */,
  1511. X    Display *           /* dpy */
  1512. X#endif
  1513. X);
  1514. X
  1515. X
  1516. X/*
  1517. X** macro definition
  1518. X*/
  1519. X
  1520. X#define LOOKUP_NODE(p,w,d)                                                     \
  1521. X    if ( ( pexutdb_last != (PEXUtDBData *)NULL ) &&                            \
  1522. X         ( ( pexutdb_last->window == w ) && ( pexutdb_last->display == d ) ) ) \
  1523. X        p = pexutdb_last;                                                      \
  1524. X    else {                                                                     \
  1525. X        p = lookup_node( w, d );                                               \
  1526. X        pexutdb_last = p;                                                      \
  1527. X    }
  1528. X
  1529. X
  1530. X#ifdef __cplusplus
  1531. X}                    /* for C++ V2.0 */
  1532. X#endif
  1533. X
  1534. X
  1535. X#endif /* _PEXUTDBINT_H_ ] */
  1536. END_OF_FILE
  1537.   if test 17902 -ne `wc -c <'util/pexutdbint.h'`; then
  1538.     echo shar: \"'util/pexutdbint.h'\" unpacked with wrong size!
  1539.   fi
  1540.   # end of 'util/pexutdbint.h'
  1541. fi
  1542. echo shar: End of archive 12 \(of 14\).
  1543. cp /dev/null ark12isdone
  1544. MISSING=""
  1545. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1546.     if test ! -f ark${I}isdone ; then
  1547.     MISSING="${MISSING} ${I}"
  1548.     fi
  1549. done
  1550. if test "${MISSING}" = "" ; then
  1551.     echo You have unpacked all 14 archives.
  1552.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1553.     echo "concatentating pexdraw.c ..."
  1554.     cat pexdrawc.? > pexdraw.c
  1555.     rm pexdrawc.?
  1556.     echo "concatentating pexdraw.uil ..."
  1557.     cat pexdrawu.? > pexdraw.uil
  1558.     rm pexdrawu.?
  1559.     echo "concatentating teapot.c ..."
  1560.     rm teapotc.?
  1561. else
  1562.     echo You still must unpack the following archives:
  1563.     echo "        " ${MISSING}
  1564. fi
  1565. exit 0
  1566. exit 0 # Just in case...
  1567. -- 
  1568.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1569. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1570.  "It's intuitively obvious to the |
  1571.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1572.