Graphics Reference
In-Depth Information
7.3
Programming Geometric Primitives
Tutorial 7.1.
Project Name:
Tutorial 7.1. Primitives and Attributes
D3D _ ObjectsAndAttributes
Library Support:
UWBGL _ MFC _ Lib1
UWBGL _ D3D _ Lib4
Goals. Get experience with some attributes for drawing geometric prim-
itives; understand that the actual programming of geometric primitives is
independent of the graphics API.
Approach. Study the implementation of a simple graphics primitive editor;
analyze an approach to decouple the general programming abstraction of
primitives from the API-dependent drawings.
Figure 7.7 is a screenshot of running Tutorial 7.1. This tutorial allows the user to
create/edit a point, a line, or a circle. In addition, the user can adjust the color,
(Gouraud) shading color, and point size attributes for these primitives. We will
analyze the library support for this tutorial and then study the CModel source code.
Figure 7.7.
Tutorial 7.1.
UWBGL_D3D_Lib4
Change summary. See p. 514
for a summary of changes to
the library.
As in all UWBGL libraries, the source files to this library are organized into three
groups.
CommonFiles folder. Contains files that implement API-independent func-
tionality. For example, we have worked with WindowHandler.h/.cpp ,
which implement abstract view/controller pair functionality; or Clock.h/
.cpp , which implement wall-clock stopwatch functionality. In this case,
because of the large number of files, we further subdivide this folder into
four subfolders.
- DrawHelper subfolder. Contains DrawHelper1.h/.cpp , which de-
fine the DrawHelper abstraction that allow us to decouple API-specific
primitive drawing from API-independent primitive behaviors.
We
will examine this class in detail.
- Geoms subfolder. Contains the source and header files for the Point
Geom , LineGeom ,and CircleGeom classes. These classes implement
the API-independent behavior of primitives. We will examine these
classes in detail.
- Utilities subfolder. Contains Containers.h , Utility2.h/.cpp ,
Color1.h/.cpp ,and Clock.h/.cpp . These files are identical to the
files from the previous library ( UWBGL _ D3D _ Lib3 ).
Search WWH ::




Custom Search