Graphics Reference
In-Depth Information
class
UWB
_
DrawHelper
{
Source file.
uwbgl
_
DrawHelper1.h/cpp
files in the
Common Files/
DrawHelper
subfolder of the
UWBGL
_
D3D
_
Lib4
project.
A:
Functions to draw geometric primitives
virtual bool
DrawPoint(
vec3
position) {
return false
;}
virtual bool
DrawLine(
vec3
start,
vec3
end) {
return false
;}
virtual bool
DrawCircle(
vec3
center,
float
radius) {
return false
;}
.
B:
Functions to set the attributes of the primitives
virtual void
ResetAttributes();
virtual void
SetShadeMode(eShadeMode mode);
// Gouraud or Flat shading
virtual void
SetFillMode(eFillMode mode);
// Wire frame or fill solid
UWB
_
Color SetColor1(UWB
_
Color color);
// color to draw
D:
Functions for supporting model transformations
virtual bool
InitializeModelTransform();
.
private
: ...
eShadeMode m
_
ShadeMode;
// enum data type for shading
m
_
FillMode;
eFillMode
// enum data type of fill mode
UWB
_
Color
m
_
Color1, m
_
Color2;
// storing the color setting
.
};
C:
Implementation of attribute setting functions
void
UWB
_
DrawHelper::SetShadeMode(eShadeMode mode) {
m
_
ShadeMode = mode; }
void
UWB
_
DrawHelper::SetFillMode(eFillMode mode) {
m
_
FillMode = mode; }
.
Listing 7.1.
The
UWB
_
DrawHelper
class (Tutorial 7.1).
and circle. As we can see, in both cases, at label A, we obtain the reference
to the D3D RC. At labels B and C, we compute the vertex positions and per-
vertex attributes (e.g., color). At label E, we issue the drawing command. At
label D, we define the results of Gouraud shading, where for a line we define
linear interpolation between
m
_
Color1
from the starting vertex to
m
_
Color2
at
the ending vertex. Although for a circle, we define all the circumference vertices
to be
m
_
Color1
with the center of the circle being
m
_
Color2
; this causes color
changing gradually from the center toward the circumference showing continuous
concentric circles with gradual color changes. The
DrawPoint()
function has a
similar structure and is not shown here.
Search WWH ::
Custom Search