@begin(header)
author: ackerman=ag@ics.uci.edu
show_author: ShowNone
author_organization: MIT
node_expert: ackerman=ag@ics.uci.edu 
expiration_date: 10/10/93
last_modifier: ackerman=ag@ics.uci.edu
last_mod_date: 10/10/91
mod_num: 3
@end(header)
The GC struct provides state information to the drawing routines.

You create a GC with the XCreateGC command:

     GC XCreateGC(display, d, valuemask, values)
           Display *display;
           Drawable d;
           unsigned long valuemask;
           XGCValues *values;

Note that this command takes a "Drawable".  A Drawable is any window or pixmap id.
If you are not on a variable-depth color workstation (ie, a high-end workstation),
you can use the RootWindow for the screen for this drawable.  

The default GC is obtained with at the Xlib level:

	GC the_GC;

	the_GC = XCreateGC(the_display,DefaultRootWindow(the_display),None,NULL);

where the_display was returned from an XOpenDisplay call previously.  You can
then use this GC in Xlib drawing calls.

However, the above code does not work correctly on some workstations (such as
Suns).  The default settings for the GC do not necessarily set the drawing colors
as you might wish.  The default GC draws in white on some systems (such as Suns).
(See the tutorial on color to learn why.)  The more correct way of creating a GC
at the Xlib level, then, is:

	GC the_GC;
	XGCValues the_values;

	the_values.foreground = BlackPixel(the_display,DefaultScreen(the_display));
	the_values.background = WhitePixel(the_display,DefaultScreen(the_display));
	the_GC = XCreateGC(the_display,DefaultRootWindow(the_display),
			   GCForeground | GCBackground, &the_values);

There are a couple of things to point out about this code.  First, you need set only
what you want in the XGCValues struct.  To indicate to Xlib what is interesting,
you "or" together the flags GCForeground and GCBackground.  Second, these flags
can be found in the header file X.h (usually in /usr/include/X11, occasionally
in /usr/local/include/X11).  The "None" used in the earlier code was just the
value 0 - or no flags being set.

There are, of course, other things you can set when you create the GC.  

If you need more information, click the "I'm Unhappy" button below, and 
ask a question.
