Immediate mode
Around the mid-1990s, 3D graphics hardware was appearing in
consumer grade desktop PCs, workstations, and game consoles. OpenGL,
at that time, appeared as a simple "immediate" API. The word "immediate"
refers to the imperative nature of the API where the user programs a
sequence of translation, rotation, and drawing commands. As an example,
the user might call the following function once per frame to draw a
triangle onscreen:
The above code would likely result in an image similar to the
following:
The API modelled the graphics card as a large state machine
with dozens of variables (such as "the current colour", modified
with glColor3d()). It also
required graphics hardware to implement multiple stacks of matrices
to control projection, object orientation, object scaling, amongst
other things.
As hardware evolved, it quickly became clear that the immediate
mode model was hard to optimize for at the driver level. Programmers
could submit vertex data and state changes in any arbitrary order
and the drivers could make very few assumptions about the immutability
of state at any given time. The immediate mode model was also grossly
inefficient in terms of how vertex data was actually specified: real
3D mesh data requires much more than just simple vertex coordinates.
A typical 3D mesh might require a colour value
(glColor()), a normal vector
(glNormal()), multiple
texture coordinate values
(glTexCoord()), fog coordinates
(glFogCoord()), and more. This results
in a huge number of function calls, even for relatively small models.
A complete example is as follows
(
source):