Graphics Reference
In-Depth Information
m _ pD3DDevice->DrawPrimitiveUP(D3DPT _ TRIANGLEFAN, 2, ... );
// Second TRIANGLEFAN: The Small Square
.
v[3].m _ point = D3DXVECTOR3 (-4,0,9.0); // Vertex V g
m _ pD3DDevice->DrawPrimitiveUP(D3DPT _ TRIANGLEFAN, 2, ... );
.
// draw red line along x axis, green along y axis, and
// blue along z axis
Step 4: present the drawing buffer in the application window.
m _ pD3DDevice->EndScene();
m _ pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
Listing 13.2. (cont.)
with graphics APIs always remains the same. In this case, the only differences be-
tween the two OnPaint() functions are the settings of the D3D matrix processors
(in Step 2) and the vertex positions of the squares (in Step 3). The difference in
vertex positions is simply the result of different coordinate systems: for the sake
of convenience, we have chosen different origins and axis directions. The ma-
trix processor settings of Step 2 require the understanding of computer graphics
cameras, which is the subject of the next chapter.
This tutorial worked with all the elements we identified earlier in this chapter.
In this case, the model is defined by the two TRIANGLEFAN primitives, the cam-
era is abstractly defined by the operations of Step 2 (to be detailed in the next
chapter), and the scene arrangements defined the positions of the squares and the
camera.
Recall that in 2D, we clearly differentiated the definition of scene hierarchy
(model) from the definition of WC window (for displaying). This clear separation
allows multiple copies of the same object, for example, rotating CArm as bullets
in Tutorial 11.9, with multiple WC windows viewing different parts of the scene.
By analogy, in 3D, the definition of the model, the camera, and the arrangement
of the scene should be clearly separated. The clear differentiation of these ele-
ments will allow multiple cameras to view different parts of the scene consisting
of multiple copies of the same model. In the next chapter, we will learn the details
and introduce abstraction for computer graphics cameras.
Search WWH ::




Custom Search