► We generate displays of filled convex polygons in four steps:
1. Define a fill pattern.
2. Invoke the polygon-fill routine.
3. Activate the polygon-fill feature of OpenGL.
4. Describe the polygons to be filled.
► A polygon fill pattern is displayed up to and including the polygon edges. Thus, there are no boundary lines around the fill region unless we specifically add them to the display.
➢ To fill the polygon with a pattern in OpenGL, we use a 32 × 32 bit mask.
➢ A value of 1 in the mask indicates that the corresponding pixel is to be set to the current color, and a 0 leaves the value of that frame-buffer position unchanged.
➢ The fill pattern is specified in unsigned bytes using the OpenGL data type Glubyte
→ GLubyte fillPattern [ ] = { 0xff, 0x00, 0xff, 0x00, ... };
➢ The bits must be specified starting with the bottom row of the pattern, and continuing up to the topmost row (32) of the pattern.
➢ This pattern is replicated across the entire area of the display window, starting at the lower-left window corner, and specified polygons are filled where the pattern overlaps those polygons
➢ Once we have set a mask, we can establish it as the current fill pattern with the function
glPolygonStipple (fillPattern);
➢ We need to enable the fill routines before we specify the vertices for the polygons that are to be filled with the current pattern
glEnable (GL_POLYGON_STIPPLE);
➢ Similarly, we turn off pattern filling with
glDisable (GL_POLYGON_STIPPLE);