Drawing to the Screen
Of course, the meat of GAPI is the ability it provides an application to write to the display buffer. To gain access to the buffer, a GAPI application callsvoid * GXBeginDraw();
This function returns the address of the frame buffer, or 0 if the buffer cannot be accessed for some reason. At this point, a GAPI application has free rein to modify the frame buffer using the pixel computations described in the previous section.The pointer returned isn't necessarily the lowest address of the frame buffer. Some systems are configured with negative offsets in the cbxPitch or cbyPitch values. This really isn't important as long as you rigorously use the pitch values to compute pixel addresses in the frame buffer.
When the drawing to the frame buffer is complete, call the following function:
int GXEndDraw();
This call does little on systems with direct access to the frame buffer. However, on systems that don't provide direct access to the frame buffer, calling GXEndDraw signals the display driver to copy the data from the phantom frame buffer to the actual frame buffer. Regardless of whether the application has direct access to the frame buffer, all GAPI applications should call GXEndDraw, if only for forward compatibility.