Graphics Reference
In-Depth Information
class
UWB
_
PointGeometry {
.
// sets m
_
point instance variable
A:
void
SetLocation(
float
x,
float
y,
float
z=0.0f);
.
// sets m
_
color instance variable
void
SetColor(
const
UWB
_
Color& color);
.
B:
void
Draw(UWB
_
DrawHelper
*
pDrawHelper)
const
;
.
C:
Source file.
uwbgl
_
PointGeom1.h/cpp
files in the
Common Files/-
Geoms
protected
:
.
vec3
m
_
point;
subfolder
of
the
UWBGL
_
D3D
_
Lib4
project.
// to store the location of the point
UWB
_
Color m
_
color;
// color attribute of the point
.
void
UWB
_
PointGeometry::Draw(UWB
_
DrawHelper
*
pDrawHelper)
const
{
.
pDrawHelper->ResetAttributes();
pDrawHelper->SetColor1(m
_
color);
pDrawHelper->SetPointSize(m
_
point
_
size);
pDrawHelper->DrawPoint(m
_
point);
}
Listing 7.4.
The
UWB
_
PointGeometry
class (Tutorial 7.1).
Point/line/circle geometries.
When a geometric primitive has access to the
DrawHelper
class, it can draw itself to the API-specific device by calling the
appropriate attribute-setting and primitive-drawing functions. For example, List-
ing 7.4 shows an API-independent
PointGeometry
class, where this class does
not contain any graphics API-specific function calls. We see that in this case,
the point class has a simple public behavior where we can set its geometry (A)
and attribute (B). The
Draw()
function simply delegates the responsibilities to
the
DrawHelper
class. If the
pDrawHelper
pointer references a
D3DDrawHelper
class (as shown in Listing 7.2), then the corresponding D3D drawing would occur.
Search WWH ::
Custom Search