Chapter 10. Primitives

Table of Contents
ggiDrawPixel — Draw, put, and get a single pixel from a visual
ggiDrawHLine — Draw, put, and get a horizontal line from a visual
ggiDrawVLine — Draw, put, and get a vertical line from a visual
ggiDrawBox — Draw, put, and get a rectangle from a visual
ggiFillscreen — Fills the entire virtual screen
ggiDrawLine — Draw a line on a visual

LibGGI has three basic types of primitives when it comes to filling rectangular areas (including the degenerate cases of horizontal and vertical lines and single pixels).

We have found three operations commonly performed on such areas:

Get/Put buffers are buffers used by the functions ggiGet*, ggiPut*, ggiPackColors and ggiUnpackPixels.

The format of the individual pixels in get/put buffers are defined by ggi_pixelformat (see the ggi_pixelformat section above).

Pixels are stored linearly, e.g. a rectangle with a width of three and a height of two will be stored with pixels (0,0) (1,0) (2,0) (0,1) (1,1), (2,1) in that order.

Get/put buffers use chunky pixels, unpacked, even if their representation in the framebuffer is packed (i.e. pixel size not multiple of 8 bits) or non-linear. Thus, the application does not need to know how to use planar or packed pixels for non-direct acccess.

Note: (You may specify use of packed buffers using the GT_SUB_PACKED_GETPUT ggi_graphtype flag, but as of this writing, no targets implement that yet.)

The get/put buffer passed to the LibGGI functions should be allocated for at least width * height * ((ggiGetPixelFormat()->size+7)/8) bytes.

(That is, the pixel size is obtained from ggi_pixelformat.size, rounded to a multiple of 8 bits (one byte), and is multiplied by the width and the height of the buffer.)