home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / sgi / 16510 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.5 KB  |  65 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!pmafire!mica.inel.gov!ux1!news.byu.edu!eff!sol.ctr.columbia.edu!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!sgigate!sgi!fido!zola!tweezers!portuesi
  3. From: portuesi@tweezers.esd.sgi.com (Michael Portuesi)
  4. Subject: Re: Port mapcolor() to regular Xlib??
  5. Message-ID: <semnh18@zola.esd.sgi.com>
  6. Sender: news@zola.esd.sgi.com (Net News)
  7. Organization: Silicon Graphics, Inc.  Mountain View, CA
  8. References:  <1992Nov15.033646.2844@socrates.umd.edu>
  9. Date: Mon, 16 Nov 92 18:58:41 GMT
  10. Lines: 53
  11.  
  12.  
  13. In article <1992Nov15.033646.2844@socrates.umd.edu>, wu@socrates.umd.edu writes:
  14. > Hello netters:
  15. >     I am trying to port mapcolor() function in GL to X.  Is there 
  16. > any way to specify a index into a color map to load a color into the 
  17. > color cell using Xlib calls?  
  18. > Current colormap in application program: 12 planes
  19. > 0-255 - regular colormap
  20. > 256-511 - gray scale
  21. > 512-767 - red
  22. > 768-1023 - blue 
  23. > etc
  24.  
  25. Yes, there is, though it's not as simple as it is in GL.
  26. (The benefit is that it is much more powerful).  GL has
  27. a very simple colomap model with one colormap for all of
  28. the GL windows on the display.
  29.  
  30. Xlib allows you to either allocate entries in the default
  31. color map provided for your window.  Or, you can allocate
  32. an entirely new colormap just for your window.
  33.  
  34. You can allocate cells in the current color map either
  35. as read-only (meaning no other program using the same
  36. color map can change them), or as read-write (meaning you
  37. own the colormap entry as with read-only, but you can
  38. change the contents).  Take a look at XAllocColor() and
  39. XAllocColorCells() calls to do each of these operations,
  40. respectively.  To change an entry(ies) in a color map
  41. once you've allocated them, see XStoreColor() and
  42. XStoreColors().
  43.  
  44. Given the application you've described, you may just
  45. want to ask the X server for a color map private to your
  46. application window.  To do this, take a look at the
  47. XCreateColorMap() and XSetWindowColorMap() calls in
  48. Xlib.
  49.  
  50. Full information about these calls can be found in
  51. "The X Window System" by Schiefler and Gettys.  This
  52. is the authoritative reference to the X Window
  53. System.  Like any reference, it's not long on tutorial
  54. information, but it does tell you everything you need
  55. to know, and it is authoritative.  For explanations,
  56. you can read the chapter on color management
  57. (chapter 7 in my copy) contained in the O'Reilly
  58. "Xlib Programming Manual," Vol. 1, by Adrian Nye.
  59.  
  60. --
  61. Michael Portuesi   Silicon Graphics, Inc.   portuesi@sgi.com
  62.