Graphics Reference
In-Depth Information
void
CGrfxWindowD3D::OnPaint()
Source file.
GrfxWindowD3D.cpp
file in
the
GrfxWindow
folder of
the
D3D
_
ViewTransform0
project.
Step 1:
select graphics hardware render buffer.
.
Step 2:
initialize selected hardware and set the coordinate system parameters.
.
// Initialize D3D matrix processors setting all three
// matrix processors to identity matrix
m
_
pD3DDevice->SetTransform(D3DTS
_
WORLD, &identity);
m
_
pD3DDevice->SetTransform(D3DTS
_
VIEW, &identity);
m
_
pD3DDevice->SetTransform(D3DTS
_
PROJECTION, &identity);
D3DXMATRIX world2ndc
;
// Coordinate Transformation operator
D3DXVECTOR3
scale(2.0f/width, 2.0f/height, 1.0f);
// Parameters for the operator
D3DXVECTOR3
translate(-1.0f, -1.0f, 0.0);
//
// compute the coordinate transformation operator
D3DXMatrixTransformation(&
world2ndc
, scale, translate);
// Load the operator into the D3D
VIEW
matrix
m
_
pD3DDevice->SetTransform(D3DTS
_
VIEW, &
world2ndc
);
Step 3:
clear drawing buffer and draw two squares.
.
v[0].m
_
point =
D3DXVECTOR3
(160,122,0);
v[1].m
_
point =
D3DXVECTOR3
( 80,122,0);
.
m
_
pD3DDevice->DrawPrimitiveUP(D3DPT
_
TRIANGLEFAN, 2, (CONST
void
*
)v,
...
);
.
Listing 10.1.
CGrfxWndD3D::
OnPaint()
(Tutorial 10.1)
WC
NDC
W
H
T(-1,-1)
(W,H)
S(
,
)
(1,1)
(2,2)
2
H
(0,0)
(0,0)
2
(0,0)
W
(-1,-1)
Figure 10.2.
The operations of
w2n
.
Search WWH ::
Custom Search