ggiBufSetGCForeground, ggiBufSetGCBackground, ggiBufSetGCFlags, ggiBufGetGCForeground, ggiBufGetGCBackground, ggiBufGetGCFlags : Set or get the foreground, background default values and flags of a buffer
#include <ggi/buf.h> int ggiBufSetGCForeground(ggiBuf_t buf, ggi_bufval val); int ggiBufSetGCBackground(ggiBuf_t buf, ggi_bufval val); int ggiBufSetGCFlags(ggiBuf_t buf, enum ggiBuf_flags flags); int ggiBufGetGCForeground(ggiBuf_t buf, ggi_bufval *val); int ggiBufGetGCBackground(ggiBuf_t buf, ggi_bufval *val); int ggiBufGetGCFlags(ggiBuf_t buf, enum ggiBuf_flags *flags);
ggiBufSetGCForeground and ggiBufGetGCForeground set and read, respectively, the current value used as a default for the channel (Alpha, Z, etc.) represented by the buffer buf when data is sent to a compound buffer or clad visual to which buf belongs, when such data has no corresponding channel. This value applies to all pixels drawn in the foreground color in two-color operations, or otherwise to all pixels.
ggiBufSetGCBackground and ggiBufGetGCBackground set and read, respectively, the current value used as a default when the buffer is cleared with ggiBufClear. This value is also used in the same way that the foreground value is used when a two-color operation like text drawing is performed, but applies only to pixels drawn in the background color.
ggiBufSetGCFlags and ggiBufGetGCFlags set and read, respectively, flags which define the default behavior of the buffer.
The following flag values are defined for both Alpha and Z buffers:
The following flag values are defined for Z buffers:
The following flags are defined for Alpha buffers and determine the type of blend performed:
Values are blended using the following rule expressed with normalized Alpha values:
D = As * S + (1 - As) * D * Ad; A = As + (1 - As) * Ad
Values are blended using the following rule expressed with normalized Alpha values:
D = Ad * D + (1 - Ad) * S * As; A = Ad + (1 - Ad) * As
Values are blended using the following rule expressed with normalized Alpha values:
D = As * S * Ad; A = As * Ad
Values are blended using the following rule expressed with normalized Alpha values:
D = Ad * D * As; A = Ad * As
Values are blended using the following rule expressed with normalized Alpha values:
D = As * S * (1 - Ad); A = As * (1 - Ad)
Values are blended using the following rule expressed with normalized Alpha values:
D = Ad * D * (1 - As); A = Ad * (1 - As)
Values are blended using the following rule expressed with normalized Alpha values:
D = As * S * Ad + (1 - As) * D * Ad; A = As * Ad + (1 - As) * Ad
Values are blended using the following rule expressed with normalized Alpha values:
D = Ad * D * As + (1 - Ad) * S * As; A = Ad * As + (1 - Ad) * As
Values are blended using the following rule expressed with normalized Alpha values:
D = As * S * (1-Ad) + (1-As) * D * Ad; A = As * (1-Ad) + (1-As) * Ad
Values are blended using the following rule expressed with normalized Alpha values:
D = As * S + Ad * D; A = As * Ad
All four functions 0 for OK or a negative value on failure. In the case of ggiSetGCFlags, failures usually mean that the display does not support the desired blend or comparison. You can avoid such failures by insisting that the blend be available when the buffer is created with ggiBufAddAlpha/ggiBufCreateAlpha or ggiBufAddZ/ggiBufCreateZ.