Page 40 - Computer Graphics Handout
P. 40
p = q;
}
cleanup();
}
This form can be converted into a real program fairly easily. However, even at
this level of abstraction, we can see two other alternatives. Consider the pseudocode
main( )
{
initialize_the_system();
p = find_initial_point();
for(some_number_of_points)
{
q = generate_a_point(p);
store_the_point(q);
p = q;
}
display_all_points();
cleanup();
}
In this algorithm, we compute all the points first and put them into an array or some other data structure. We then display all the
points through a single function call. This approach avoids the overhead of sending small amounts of data to the graphics processor
for each point we generate at the cost of having to store all the data. The strategy used in the first algorithm is known as immediate
mode graphics and, until recently, was the standard method for displaying graphics, especially where interactive performance was
needed. One consequence of immediate mode is that there is no memory of the geometric data. With our first example, if we want
to display the points again, we would have to go through the entire creation and display process a second time.
In our second algorithm, because the data are stored in a data structure, we can redisplay the data, perhaps with some changes
such as altering the color or changing the size of a displayed point, by resending the array without regenerating the points.
The method of operation is known as retained mode graphics and goes back to some of the earliest special purpose graphics display
hardware. The architecture of modern graphics systems that employ a GPU leads to a third version of our program. Our second
approach has one major flaw. Suppose that, as we might in an animation, we wish to redisplay the same objects. The geometry of
the objects is unchanged, but the objects may be moving. Displaying all the points involves sending the data from the CPU to the
GPU each time we wish to display the objects in a new position. For large amounts of data, this data transfer is the major bottleneck
in the display process. Consider the following alternative scheme:
main( )
{
initialize_the_system();
p = find_initial_point();
for(some_number_of_points)
{
q = generate_a_point(p);
store_the_point(q);
p = q;
}
send_all_points_to_GPU();
display_data_on_GPU();
cleanup();
}
As before, we place data in an array, but now we have broken the display process into two parts: storing the data on the GPU and
displaying the data that has been stored. If we only have to display our data once, there is no advantage over our previous method,
but if we want to animate the display, our data are already on the GPU and redisplay does not require any additional data transfer,
only a simple function call that alters the location of some spatial data describing the objects that have moved.
Although our final OpenGL program will have a slightly different organization, it will follow this third strategy. We develop the full
program in stages. First, we concentrate on the core: generating and displaying points. We must answer two questions:
How do we represent points in space?
Should we use a two-dimensional, three-dimensional, or other representation?
40

