home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sgi:13619 comp.windows.x.motif:6175
- Newsgroups: comp.sys.sgi,comp.windows.x.motif
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uchinews!iitmax!chien
- From: chien@iitmax.iit.edu (Greg Chien)
- Subject: Colormap on Indigo XS24
- Message-ID: <1992Sep14.183026.4852@iitmax.iit.edu>
- Keywords: Pseudo Color Colormap Indigo X11 X Windows
- Organization: Illinois Institute of Technology / Academic Computing Center
- Date: Mon, 14 Sep 92 18:30:26 GMT
- Lines: 244
-
- Hi,
-
- The following program runs on an SGI IRIS 320/VGX and a few Personal
- IRISes but just doesn't like the Indigos. Can anyone point out what
- I have missed? or anything related to Indigo's Virtual 24 scheme?
- I am running it only in PseudoColor mode.
-
- Thanks in advance,
- Greg
- ===========================================================================
- | Greg T.H. Chien It is engineered, not designed. |
- | Illinois Institute of Technology Phone: (312) 567-5922 |
- | Dept. of Computer Science, 237SB BITNET: THSSCHIEN@IITVAX |
- | Chicago, IL 60616 Internet: chien@iitmax.iit.edu |
- ===========================================================================
- /* -------- 8< --------------- CUT HERE ------------ 8< ------------- */
- /* colortest.c - test color ramp setup
- *
- * This program instantiates a DrawingArea and sets up a
- * color ramp in color pixel index 128-256. It cycles
- * through the color ramp and clears the DrawingArea
- * using the colors as the DrawingArea's background after
- * the Start button is hit.
- * compile with: cc -o colortest colortest.c -lXm -lXt -lX11
- */
-
- #include <Xm/Xm.h>
- #include <Xm/DrawingA.h>
- #include <Xm/RowColumn.h>
- #include <Xm/PushB.h>
-
- #define MAXCOLORS 256
- #define MAXRGBVAL 65535
- #define BASECOLORS 128
-
- Display *dpy;
- Colormap my_colormap;
- int ncolors;
- Widget canvas;
-
- void start(w, cl, ca)
- Widget w;
- XtPointer cl, ca;
- {
- int i;
-
- for (i = BASECOLORS; i < ncolors; i++) { /* cycle through color ramp */
- XtVaSetValues(canvas, XmNbackground, i, NULL);
- XClearWindow(dpy, XtWindow(canvas));
- }
- }
-
- void quit(w, cl, ca)
- Widget w;
- XtPointer cl, ca;
- {
- XtCloseDisplay(dpy);
- exit(0);
- }
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int i;
- int nrampcolors, qtrnramp, delta;
- int quarter, index, offset;
- XtAppContext app_context;
- Widget toplevel, base, control;
- Widget startB, quitB;
- Colormap def_colormap;
- XColor Colors[MAXCOLORS];
- XmString xmstr;
-
- toplevel = XtAppInitialize(&app_context, "Coloredit", NULL, 0,
- &argc, argv, NULL, NULL);
- dpy = XtDisplay(toplevel);
-
- ncolors = DisplayCells(dpy, DefaultScreen(dpy));
- if (ncolors > MAXCOLORS) ncolors = MAXCOLORS;
-
- base = XtCreateManagedWidget("base",xmRowColumnWidgetClass,
- toplevel, NULL, 0);
- canvas = XtCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
- base, NULL, 0);
- XtVaSetValues(canvas, XmNwidth, 400, XmNheight, 400, NULL);
-
- control = XtCreateManagedWidget("control", xmRowColumnWidgetClass,
- base, NULL, 0);
-
- startB = XtCreateManagedWidget("startB", xmPushButtonWidgetClass,
- control, NULL, 0);
- quitB = XtCreateManagedWidget("quitB", xmPushButtonWidgetClass,
- control, NULL, 0);
-
- xmstr = XmStringCreate("Start", XmSTRING_DEFAULT_CHARSET);
- XtVaSetValues(startB, XmNlabelString, xmstr);
- XmStringFree(xmstr);
- xmstr = XmStringCreate("Quit", XmSTRING_DEFAULT_CHARSET);
- XtVaSetValues(quitB, XmNlabelString, xmstr);
- XmStringFree(xmstr);
-
- XtAddCallback(startB, XmNactivateCallback, start, NULL);
- XtAddCallback(quitB, XmNactivateCallback, quit, NULL);
-
- def_colormap = DefaultColormap(dpy, DefaultScreen(dpy));
- for(i = 0; i < ncolors; i++ ) {
- Colors[i].pixel = i;
- Colors[i].flags = DoRed|DoGreen|DoBlue;
- }
-
- XQueryColors(dpy, def_colormap, Colors, ncolors);
-
- nrampcolors = ncolors - BASECOLORS;
- qtrnramp = nrampcolors / 4;
- delta = MAXRGBVAL / qtrnramp;
- for (i = 0; i < nrampcolors; i++) { /* setting up color ramp */
- quarter = i / qtrnramp;
- index = i % qtrnramp;
- offset = i + BASECOLORS;
- switch (quarter) {
- case 0:
- Colors[offset].blue = MAXRGBVAL;
- Colors[offset].green = index * delta;
- Colors[offset].red = 0;
- break;
- case 1:
- Colors[offset].blue = (qtrnramp - index) * delta;
- Colors[offset].green = MAXRGBVAL;
- Colors[offset].red = 0;
- break;
- case 2:
- Colors[offset].blue = 0;
- Colors[offset].green = MAXRGBVAL;
- Colors[offset].red = index * delta;
- break;
- case 3:
- Colors[offset].blue = 0;
- Colors[offset].green = (qtrnramp - index) * delta;
- Colors[offset].red = MAXRGBVAL;
- break;
- default:
- break;
- }
- }
-
- my_colormap = XCreateColormap(dpy, DefaultRootWindow(dpy),
- DefaultVisual(dpy, DefaultScreen(dpy)),
- AllocAll);
- XStoreColors(dpy, my_colormap, Colors, ncolors);
-
- XtRealizeWidget(toplevel);
-
- XSetWindowColormap(dpy, XtWindow(toplevel), my_colormap);
-
- XtAppMainLoop(app_context);
- }
- /* -------- 8< --------------- CUT HERE ------------ 8< ------------- */
- #ifdef INFO_BELOW
-
- xwininfo output from an Indigo XS24
-
- xwininfo ==> Please select the window about which you
- ==> would like information by clicking the
- ==> mouse in that window.
-
- xwininfo ==> Window id: 0x280000f (colortest)
-
- ==> Absolute upper-left X: 590
- ==> Absolute upper-left Y: 104
- ==> Relative upper-left X: 0
- ==> Relative upper-left Y: 0
- ==> Width: 406
- ==> Height: 476
- ==> Visual: 0x25 (8 bit PseudoColor)
- ==> Border width: 0
- ==> Window class: InputOutput
- ==> Colormap: 0x280000e (installed)
- ==> Window Bit Gravity State: NorthWestGravity
- ==> Window Window Gravity State: NorthWestGravity
- ==> Window Backing Store State: NotUseful
- ==> Window Save Under State: no
- ==> Window Map State: IsViewable
- ==> Window Override Redirect State: no
- ==> Corners: +590+104 -284+104 -284-444 +590-444
-
- Portion of the xdpyinfo output from an Indigo XS24
-
- visual:
- visual id: 0x25
- class: PseudoColor
- depth: 8 planes
- size of colormap: 256 entries
- red, green, blue masks: 0x0, 0x0, 0x0
- significant bits in color specification: 8 bits
-
- ------------------------------------------------------------------
-
- xwininfo output from a PI30 with Turbo Graphics
-
- xwininfo ==> Please select the window about which you
- ==> would like information by clicking the
- ==> mouse in that window.
-
- xwininfo ==> Window id: 0x300000f (colortest)
-
- ==> Absolute upper-left X: 610
- ==> Absolute upper-left Y: 213
- ==> Relative upper-left X: 0
- ==> Relative upper-left Y: 0
- ==> Width: 406
- ==> Height: 476
- ==> Visual: 0x20 (8 bit PseudoColor)
- ==> Border width: 0
- ==> Window class: InputOutput
- ==> Colormap: 0x300000e (not installed)
- ==> Window Bit Gravity State: NorthWestGravity
- ==> Window Window Gravity State: NorthWestGravity
- ==> Window Backing Store State: NotUseful
- ==> Window Save Under State: no
- ==> Window Map State: IsViewable
- ==> Window Override Redirect State: no
- ==> Corners: +610+213 -264+213 -264-335 +610-335
-
- Portion of the xdpyinfo output from a PI30 with Turbo Graphics:
-
- visual:
- visual id: 0x20
- class: PseudoColor
- depth: 8 planes
- size of colormap: 256 entries
- red, green, blue masks: 0x0, 0x0, 0x0
- significant bits in color specification: 8 bits
-
- ------------------------------------------------------------------
- #endif /* INFO_BELOW */
-
- --
- ===========================================================================
- | Greg T.H. Chien It is engineered, not designed. |
- | Illinois Institute of Technology Phone: (312) 567-5922 |
- | Dept. of Computer Science, 237SB BITNET: THSSCHIEN@IITVAX |
- | Chicago, IL 60616 Internet: chien@iitmax.iit.edu |
- ===========================================================================
-