 |
GrayDBufInit |
Function (Macro) |
Initializes grayscale double-buffering mode.
GrayDBufInit initializes double-buffering mode. In double-buffering mode, you
can switch between two buffers (using
GrayDBufToggle) very quickly; much more
quickly than using memcpy to achieve
double-buffering. This function assumes that
GrayOn has been called and its result was
successful. To have as little extra double-buffering code in the grayscale
implementation as possible, you need to allocate your own buffer and pass it
to this function. You can do this with
malloc, for example, but be sure to
check its result before proceeding. The necessary size of the buffer (in
bytes) is specified by the constant
GRAYDBUFFER_SIZE.
You do not explicitly need to call
GrayDBufCleanup to deactivate
double-buffering mode; GrayOff will do the
necessary uninitialization. However, be sure to free the buffer after calling
GrayDBufCleanup or
GrayOff.
The contents of the current grayscale buffer become the new contents of the
plane with index 0 (see
GrayDBufGetActiveIdx). The plane
with index 1 is initialized from the new buffer and is filled either with
random contents or with zeroes, depending on the contents of buf. Do
not attempt to change the contents of buf directly after calling
GrayDBufInit.
Note: After calling this function, you should not use the standard
grayscale functions GrayGetPlane and
GraySetAMSPlane any more. Instead, use
the double-buffering functions
GrayDBufGetPlane and
GrayDBufSetAMSPlane or related
ones.
See also: GrayDBufCleanup, GrayDBufSetActiveIdx, GrayDBufToggle