Graphics Reference
In-Depth Information
Compatibility Profile, no longer considered a mainstream part of the API. Simi-
larly, starting with Direct3D 10, the FF pipeline is no longer available. Thus, the
modern IMAPI is leaner, with far fewer graphics-related entry points, as described
in Section 16.3.
16.2 The Programmer's Model: OpenGL
Compatibility (Fixed-Function) Profile
In this section, we illustrate the techniques involved in the use of a fixed-function
IM platform; to serve as the example platform, we have chosen OpenGL 2 in light
of its OS- and language-independence.
OpenGL uses a client/server model in which the application acts as the client
(with the CPU being its processing resource and main-memory RAM being the
memory resource), and the graphics hardware is the server (with its resources
being the GPU and its associated high-performance RAM used for storing mesh
geometry, textures, etc.).
The API provides a very thin layer that translates API calls into instructions
pushed from client to server. In this section, we focus on the fixed-function API,
which is now part of OpenGL's Compatibility Profile. Its fixed-function IM plat-
form operates as a state machine. For the most part, each API call either sets a
global state variable (e.g., the current color) or launches an operation that uses
the global state to determine how it should operate.
State variables are used to store all information that affects how a geometric
primitive is to be placed/viewed (e.g., modeling transformations, camera charac-
teristics) and how it should appear (e.g., materials). State variables also help you
control the behavior of the graphics pipeline by enabling or disabling certain ren-
dering features (e.g., fog).
As an example, consider this pseudocode illustrating state-machine-based
generation of three 2D primitives:
1
2
3
4
5
6
7
SetState (LineStyle, DASHED);
SetState (LineColor, RED);
DrawLine ( PtStart = (x1,y1), PtEnd = (x2,y2) ); // Dashed, red
SetState (LineColor, BLUE);
DrawLine ( PtStart = (x2,y2), PtEnd = (x3,y3) ); // Dashed, blue
SetState (LineStyle, SOLID);
DrawLine (
PtStart = (x3,y3), PtEnd = (x4,y4) ); // Solid, blue
This strategy contrasts with that of an object-oriented system such as
WPF, which binds the primitive and its attributes together as illustrated in this
pseudocode:
1
2
3
4
5
6
7
8
BundleDASHR =
AttributeBundle( LineStyle = DASHED, LineColor = RED );
BundleDASHB =
AttributeBundle( LineStyle = DASHED, LineColor = BLUE );
BundleSOLIDB =
AttributeBundle( LineStyle = SOLID, LineColor = BLUE );
DrawLine ( Appearance=BundleDASHR,
PtStart = (x1,y1), PtEnd = (x2,y2) );
2. At a high level, Direct3D's programmer's model is similar, although its API is not.
 
 
 
Search WWH ::




Custom Search