Return to previous page | Return to menu | Go to next page


Polygon drawing routine

Use the library function “slPutPolygon” to draw polygons with SGL. This function draws the polygon specified as a parameter, but the display position and various conversion operations (rotation, translation, scaling) follow the current matrix.

[void slPutPolygon (PDATA * pat);]
Draw polygons with data defined. For the parameter, substitute the top address of the polygon data table that contains the polygon vertex data list, vertex count, face list, face count, and face attribute data. For details on the parameters, refer to “Parameters required for polygon drawing” in the next section.

Hereafter, I will explain with reference to the sample program.

In the sample program, after making the necessary preparations for polygon drawing (initialization, setting of coordinates and display angle, etc.), display the polygons using the hierarchy matrix concept (see “Chapter 5: Matrix” for details). The position, display angle, enlargement / reduction ratio (unused in this case) are determined, and actual polygon drawing is performed based on these data.
The library function “slPutPolygon (& PD_DATA):” is used to draw polygons.
“& PD_DATA” in parentheses is a variable that collects the parameters necessary for polygon display and is defined in the data file “polygon.c”. (See “List 2-2: polygon.c: Polygon parameters”.)

List 2-1 sample_2_2: Polygon drawing routine

Flow 2-1 sample_2_2: Polygon drawing flowchart


Return to previous page | Return to menu | Go to next page