Graphics Reference
In-Depth Information
bool
UWBD3D
_
DrawHelper::DrawLine(
vec3
start,
vec3
end) {
A:
LPDIRECT3DDEVICE9
pDevice = UWBD3D
_
GraphicsSystem::GetSystem().GetD3DDevice();
.
Source file.
uwbgl
_
D3DDrawHelper1.cpp
file in the
D3D Files/-
DrawHelper
subfolder of the
UWBGL
_
D3D
_
Lib4
project.
// Set the start point positions
B:
draw
_
points[0].m
_
point.x = start.x;
.
// Per vertex color
C:
draw
_
points[0].m
_
color = m
_
Color1.ARGB();
.
// Gouraud shading interpolates
D:
if
(m
_
ShadeMode == smFlat)
draw
_
points[1].m
_
color = m
_
Color1.ARGB();
// from m
_
Color1 to m
_
Color2
else
// along the line
draw
_
points[1].m
_
color = m
_
Color2.ARGB();
.
E:
pDevice->DrawPrimitiveUP(D3DPT
_
LINELIST, 1, (CONST
void
*
)(&draw
_
points),
sizeof
(.));
.
bool
UWBD3D
_
DrawHelper::DrawCircle(
vec3
center,
float
radius) {
A:
LPDIRECT3DDEVICE9
pDevice = UWBD3D
_
GraphicsSystem::GetSystem().GetD3DDevice();
.
B/C:
// Compute vertex positions for the TriangleFan,
// fill the circumference vertices with m
_
Color1
.
// for Gouraud shading, set the center color to m
_
Color2
D:
if
( smGouraud == m
_
ShadeMode )
v[0].m
_
color = m
_
Color2.ARGB();
// causing interploation from
// circumference toward the center
.
E:
pDevice->DrawPrimitiveUP(D3DPT
_
TRIANGLEFAN, kNumPts-2, (CONST
void
*
)v,
sizeof
(.));
.
Listing 7.3.
The
UWBD3D
_
DrawHelper
draw functions (Tutorial 7.1).
Search WWH ::
Custom Search