executing the OpenGL display tableuse the following statement to perform a display table:
Glcalllist (ListID);
The following program segment is used to create and execute a display table. We first establish a display table of the rule hexagon on the XY plane that describes the six equidistant vertices on a circle with a center coordinate of (200,200) and a radius of 150. However, call Glcalllist to display the hexagon.
Const double TWO_PI = 6.2831853; Gluint Reghex; Gldouble Theta; Glint x, y, K; /* Set up a display list for a regular hexagon. * Vertices for the hexagon is six equally spaced * points around the circumference of a circle. */Reghex = glgenlists (1); Get an identifier for the display list. Glnewlist (Reghex, gl_compile); Glbegin (Gl_polygon); for (k = 0; k < 6; k++) { theta = Two_pi * k/6.0; x = + + * cos (theta); y = + * sin (theta); Glvertex2i (x, y); } Glend (); Glendlist (); Glcalllist (Reghex);
You can perform multiple display tables using the following two statements:
Gllistbase (Offsetvalue); Glcalllists (nlists, Arraydatatype, Listidarray);
The number of display tables to execute is assigned to the parameter
nlists, and the parameter
ListidarrayIsdisplays an array of table identities。Generally, Listidarray can contain any number of elements, while invalid identities are ignored。 Similarly, elements in Listidarray can be specified in a variety of data formats, while parameters
Arraydatatypeused to indicate data typesFor examplegl_byte,gl_int,gl_float, gl_3_bytes or gl_4_ BYTES. The display table identifies the
ListidarrayThe value of one element in the
OffsetvalueInteger values are added together.
OffsetvalueThe default value is 0.
This mechanism of specifying a list of displayed tables allows us to create a set of related display tables whose identities are formed by symbolic names or encodings。 A typical example is a set of fonts, where each display table identifies an ASCII value of one character. When defining several fonts, use the
gllistbase functionIn the
OffsetvaiueTo get the array
ListidarraySpecific fonts described in the.
Computer Graphics (ii) OUTPUT elements _18_ display list _2_ performing OpenGL display table