DrawTrap
Draws a solid trapezoid.
Declaration
void NAPI GA_2DRenderFuncs::DrawTrap(
GA_trap *trap)
Prototype In
snap/graphics.h
Parameters
trap |
Pointer to the GA_trap structure describing the trapezoid |
Description
This function renders a solid, flat topped and bottomed trapezoid in the currently active color and mix. The parameters for the trapezoid to be rendered are passed in the GA_trap structure (note that all coordinates are in 16.16 fixed point format). This function will always be provided, and will be the workhorse function for rendering solid 2D polygons. After this function has been called, the driver will have updated the y, x1 and x2 variables in the GA_trap structure to reflect the final values after scan converting the trapezoid. This ensures that the high level code can properly join up connected trapezoids to complete the rendering of a larger more complex polygon. The standard algorithm for implementing this is C is as follows (note that it handles edges that can cross within the trapezoid properly):
// Get input parameters into locals
N_int32 y = trap.y;
N_fix32 x1 = trap.x1;
N_fix32 x2 = trap.x2;
// Scan the trapezoid
while (trap.count--) {
int ix1 = FIXROUND(x1);
int ix2 = FIXROUND(x2);
if (ix2 < ix1)
SWAP(ix1,ix2);
if (ix1 < ix2)
scanLine(trap.y,ix1,ix2);
x1 += slope1;
x2 += slope2;
y++;
}
// Update returned input parameters
trap.y = y;
trap.x1 = x1;
trap.x2 = x2;
See Also
Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com