Contents / Previous / Next


Rectangles

Since rectangles are so common in graphics applications, OpenGL provides a filled-rectangle drawing primitive, glRect*() optimized for rectangles:

void glRect{sifd}( TYPEx1, TYPEy1, TYPEx2, TYPEy2 );

void glRect{sifd}v( TYPE*v1, TYPE*v2 );

glRect*() draws the rectangle defined by the corner points (x1, y1) and (x2, y2). The rectangle lies in the plane z=0 and has sides parallel to the x- and y-axes. If the vector form of the function is used, the corners are given by two pointers to arrays, each of which contains an (x, y) pair.

Note that although the rectangle begins with a particular orientation in three-dimensional space (in the x-y plane and parallel to the axes), you can change this by applying rotations or other transformations.