johnl@esegue.segue.boston.ma.us (John R. Levine) (10/19/90)
I'm writing some X code that draws pictures in a moderate number of colors, most often six or eight. I realize that every X server is different, but are there any rules of thumb that say whether I'm better off making eight GCs for my eight colors, or using one GC and changing its colors with XSetForeground and XSetBackground? Both efficiency and style arguments would be interesting. -- John R. Levine, IECC, POB 349, Cambridge MA 02238, +1 617 864 9650 johnl@esegue.segue.boston.ma.us, {ima|spdcc|world}!esegue!johnl Atlantic City gamblers lose $8200 per minute. -NY Times
mouse@LARRY.MCRCIM.MCGILL.EDU (10/20/90)
> I'm writing some X code that draws pictures in a moderate number of > colors, most often six or eight. I realize that every X server is > different, but are there any rules of thumb that say whether I'm > better off making eight GCs for my eight colors, or using one GC and > changing its colors with XSetForeground and XSetBackground? > Both efficiency and style arguments would be interesting. The only implementation with which I am familiar to the level of knowledge necessary to comment on efficiency is the MIT Xsun, which does it all in software anyway, where the performance difference is entirely due to the extra memory used in the server (for multiple GCs) and the extra network bandwidth used for the change requests (for one GC). Thus, in this case, you will usually be better off using multiple GCs, but that won't apply everywhere. As for style, I would say that style would dictate that if the different colors indicate conceptually different things being drawn, you should use different GCs, but if it indicates one conceptual thing which happens to be rendered with different colors, you should use one GC. In a video game, for example, where ships are blue and shots are sometimes red and sometimes green, I would say that style calls for two GCs: one for ships, which is always set to draw in blue, and one for shots, which is switched between red and green as necessary. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu