Graphics Reference
In-Depth Information
void CDrawOnlyHandler::DrawGraphics()
float width = 300.0f, height=300.0f;
Source file.
DrawOnlyHandler.cpp
file in the WindowHandler
folder of the D3D _ XformList
project.
.
// Construct the matrix that will transform from the world bounds
// to NDC
D3DXVECTOR3 scale(2.0f/width, 2.0f/height, 1.0f);
D3DXVECTOR3 translate(-1.0f, -1.0f, 0.0);
D3DXMatrixTransformation(& world2ndc , ... &scale, ... &translate);
m _ pD3DDevice->SetTransform(D3DTS _ VIEW, & world2ndc );
.
Listing 10.3. The DrawGraphics() function of Tutorial 9.9.
Figure 10.8 illustrates the transformation that takes place. Note the following.
Step 1. The M w 2 n operator transforms all vertices from our design space
into the NDC. In this case, the design and measurements are based on a
drawing area of width = 300 and height = 300. In the implementation of
Tutorial 9.9, the values for the width and height are fixed based on the
width and height of the application window. However, notice that the input
of the M w 2 n transformation is our design space and that the output is the
NDC space. In fact, neither the input nor the output is related to the DC
dimension!
Step 2. The M n 2 d operator is internal to the D3D graphics API. This oper-
ator transforms all vertices from the NDC to the final application drawing
area, or the device coordinate (DC). Notice that this transformation, M n 2 d ,
M w2n
We
c omput this
M n2d
D3D
Automatically
1
(1,1)
-1
1
(-1,-1)
-1
Our Original
Design
UI Drawing
Area
Internal
To D 3 D
DC
WC
NDC
Figure 10.8.
Transformation for drawing of the face in Figure 9.21.
 
 
 
 
Search WWH ::




Custom Search