Module 2 ppt
Module 2 ppt
Chapter 3
INPUT AND INTERACTION
3.4 Display List
• Display lists illustrate how we can use clients and servers on a network to
improve interactive graphics performance.
• A special-purpose computer, called a display processor, with an organization
like that illustrated in Figure 3.13.
• The user program was processed in the host computer, resulting in a compiled
list of instructions that was then sent to the display processor, where the
instructions were stored in a display memory as a display file, or display list.
• For a simple noninteractive application, once the display list was sent to the
display processor, the host was free for other tasks, and the display processor
would execute its display list repeatedly at a rate sufficient to avoid flicker.
• The display processor of old has become a graphics
server, and the application program on the host computer
has become a client.
• The display list is stored in the server and redisplayed by a
simple function call issued from the client to the server.
• We can send graphical entities to a display in one of two
ways.
• Immediate Mode
• Retain Mode
• We can send the complete description of our objects to
the graphics server.
Immediate Mode
• As soon as the program executes a statement that defines a
primitive, that primitive is sent to the server for possible display
and no memory of it is retained in the system.
• To redisplay the primitive after a clearing of the screen, or in a
new position after an interaction, the program must specify the
primitive and then must resend the information through the
display process.
Retained-mode
• We define the object once, and then put its description in a
display list.
• The display list is stored in the server and redisplayed by a simple
function call issued from the client to the server.
Disadvantages to the use of display lists.
• Display lists require memory on the server, and
there is the overhead of creating a display list.
• Although this overhead is often offset by the
efficiency of the execution of the display list, it
might not be if the data are changing.
3.4.1 Definition and Execution of Display Lists
• Display lists have much in common with ordinary files.
• Display lists are defined similarly to geometric primitives.
• There is a glNewList at the beginning and a glEndList at the end, with the
contents in between.
• For example, the following code defines a red box as an output.
• Each display list must have a unique identifier—an integer that is
usually macro defined in the C program by means of a #define
directive to an appropriate name for the object in the list.
• The flag GL_COMPILE tells the system to send the list to the server
but not to display its contents.
• If we want an immediate display of the contents while the list is
being constructed, we can use the GL_COMPILE_AND_EXECUTE
flag instead.
• Each time that we wish to draw the box on the server, we execute
the function as follows:
glCallList(BOX);
3.4.2 Text and Display Lists
• We introduced both stroke and raster text.
• Regardless of which type we choose to use, we need a reasonable amount of
code to describe a set of characters.
• For example, suppose that we use a raster font in which each character is
stored as an 8 × 13 pattern of bits.
• It takes 13 bytes to store each character.
• If we want to display a string by the most straightforward method, we can
send each character to the server each time that we want it displayed.
• This transfer requires the movement of at least 13 bytes per character.
• If we define a stroke font using only line segments, each character can require
a different number of lines.
• If we use filled polygons for characters, as shown in Figure 3.14, we see
that an “I” is fairly simple to define, but we may need many line segments
to get a sufficiently smooth “O.”
• On the average, we need many more than 13 bytes per character to
represent a stroke font.
• For applications that display large quantities of text, sending each character
to the display every time that it is needed can place a significant burden on
our graphics systems.
3.4.3 Fonts in GLUT
• Prefer to use an existing font rather than to define our own.
• GLUT provides a few raster and stroke fonts.
• We can access a single character from a monotype, or evenly spaced,
font by the following function call:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();