home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / sgi / 12624 < prev    next >
Encoding:
Text File  |  1992-08-19  |  4.9 KB  |  157 lines

  1. Path: sparky!uunet!ogicse!hp-cv!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!dweber
  2. From: dweber@ncsa.uiuc.edu (Daniel Weber)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Hardware/Colormap differences?
  5. Message-ID: <Bt8zts.EFz@news.cso.uiuc.edu>
  6. Date: 19 Aug 92 20:34:40 GMT
  7. Article-I.D.: news.Bt8zts.EFz
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Reply-To: dweber@ncsa.uiuc.edu
  10. Organization: National Center for Supercomputing Applications
  11. Lines: 143
  12. Originator: dweber@nvs.ncsa.uiuc.edu
  13.  
  14.  
  15. I have some questions about the behavior of gl colormaps on different
  16. hardware platforms.  (Yes, another question from me about colormaps.)
  17.  
  18. Attached to this question is a program "cmap.c" that can be compiled using:
  19.  
  20.     cc cmap.c -o cmap -lXirisw -lXm_s -lXt_s -lgl_s -lX11_s -lPW -lc_s
  21.  
  22. And here is the machine setups I have to run it on:
  23.         IRIX 4.0.5
  24.         1 IRIS Indigo Entry Sys. w/ 8 bits Color
  25.         1 VGX with an R4000 upgrade
  26.  
  27. When I run this on the VGX, unless the mouse is in the window, the first N
  28. (128?) polygons are weird colors.  Once the mouse is moved into the window,
  29. the polygons are correctly colored, but now the rest of the screen's colors
  30. are freaky.
  31.  
  32. When I run this program on our Indigo, the colormap is loaded correctly and
  33. the gl window gets filled with grayscale polygons, as it should *WITHOUT*
  34. the rest of the screen changing!  (I should say that the first time it is run,
  35. the whole screen looks like the VGX version until the mouse is moved outside 
  36. the program's window, but retains the normal screen colors when the mouse is 
  37. moved back in.  Subsequent invocations don't even affect the root window 
  38. colors at all.)
  39.  
  40. Why does the Indigo behave as I truly want this program to behave?  That is,
  41. I *want* to be able to change the gl colormap *without* the rest of the 
  42. screen flaking out.  I've tried various things to change the VGX version's
  43. behavior, but to no avail.  How is it that the Indigo is capable of doing
  44. this, yet the "better" VGX is not?  It once looked like "multimap" would
  45. solve the problem, but that apparently doesn't work with the new widgets?
  46.  
  47.                                     -d weber
  48.                                     dweber@ncsa.uiuc.edu
  49.  
  50. ps.  I can't "just set the upper N colormap values" leaving the others alone
  51. as usually suggested when dealing with X colormaps.  Forcing the range is 
  52. unfortunately out of the question.
  53.  
  54.  
  55.  
  56. /*
  57.  * When running, click the mouse in the window to get the gray rectangles.
  58.  */
  59. #include <stdio.h>
  60. #include <X11/Xlib.h>
  61. #include <X11/StringDefs.h>
  62. #include <X11/Intrinsic.h>
  63. #include <Xm/Xm.h>
  64. #include <gl/glws.h>
  65. #include <X11/Xirisw/GlxMDraw.h>
  66. #include <gl.h>
  67. #include <device.h>
  68.  
  69.  
  70. /* Draws bars on input (mouse click in window).  */
  71. void drawBarsCB(Widget widget, caddr_t ignored, caddr_t unused)
  72. {
  73.     float                i = 0.0;
  74.     static float    rect[4][2] = {{0.0,0.0},{1.0,0.0},{1.0,256.0},{0.0,256.0}};
  75.     GL_Object        rectangle;
  76.  
  77.    rectangle = genobj();
  78.     makeobj(rectangle);
  79.         bgnpolygon();
  80.             v2f(rect[0]); v2f(rect[1]); v2f(rect[2]); v2f(rect[3]); v2f(rect[0]);
  81.         endpolygon();
  82.     closeobj();
  83.  
  84.     ortho2(0.0, 256.0, 0.0, 256.0);
  85.     for (i = 0.0; i < 256.0; i+=1.0) {
  86.         color(i);
  87.         callobj(rectangle);
  88.         translate(1.0, 0.0, 0.0);
  89.     }
  90.  
  91. } /* drawBarsCB */
  92.  
  93.  
  94. void exposeCB(Widget widget, Widget appShell, caddr_t unused)
  95. {
  96.     int            c, ac = 0;
  97.     Arg            args[3];
  98.     XColor        colors[256];
  99.     Colormap        colormap;
  100.     XVisualInfo    *visual;
  101.     Window        windows[2];
  102.     Display        *display = XtDisplay(widget);
  103.  
  104.     windows[0] = XtWindow(widget);
  105.     windows[1] = XtWindow(appShell);
  106.     GLXwinset(display, windows[0]);
  107.     XSetWMColormapWindows(XtDisplay(appShell), XtWindow(appShell), windows, 2);
  108.  
  109.    XtSetArg(args[ac], XtNvisual, &visual); ac++;
  110.    XtGetValues(widget, args, ac);
  111.     colormap = XCreateColormap(display, windows[0], visual->visual, AllocAll);
  112.  
  113.     for (c = 0; c < 256; c++) {
  114.         colors[c].pixel = c;
  115.         colors[c].red=colors[c].green=colors[c].blue=(unsigned short)(c << 8);
  116.         colors[c].flags = DoRed | DoGreen | DoBlue;
  117.    }
  118.  
  119.     ac = 0;
  120.     XtSetArg(args[ac], XtNcolormap, colormap); ac++;
  121.     XtSetValues(widget, args, ac);
  122.     XStoreColors(display, colormap, colors, 256);
  123.  
  124. } /* exposeCB */
  125.  
  126.  
  127. void createGLWidget(Widget appShell)
  128. {
  129.     Widget        glWidget;
  130.    GLXconfig    glxConfig[] = { {0, 0, 0} };
  131.    Arg            args[10];
  132.    int            ac = 0;
  133.  
  134.    XtSetArg(args[ac], GlxNglxConfig, glxConfig); ac++;
  135.     XtSetArg(args[ac], XtNwidth, 512); ac++;
  136.     XtSetArg(args[ac], XtNheight, 512); ac++;
  137.    glWidget = GlxCreateMDraw(appShell, "CMapTest", args, ac);
  138.    XtAddCallback(glWidget, GlxNexposeCallback, exposeCB, appShell);
  139.    XtAddCallback(glWidget, GlxNexposeCallback, drawBarsCB, NULL);
  140.    XtManageChild(glWidget);
  141.  
  142. } /* createGLWidget */
  143.  
  144.  
  145. main(int argc, char *argv[])
  146. {
  147.     Widget            appShell;                /* The top level application sh    */
  148.     XtAppContext    appContext;                /* The application context    */
  149.  
  150.    appShell = XtInitialize(argv[0], "Testcmap", NULL, 0, &argc, argv);
  151.    appContext = XtWidgetToApplicationContext(appShell);
  152.  
  153.    createGLWidget(appShell);
  154.    XtRealizeWidget(appShell);
  155.     XtMainLoop();
  156. }
  157.