Platform SDK: DirectX |
The information in this section pertains only to applications written in C and C++. See Direct3D Immediate Mode Visual Basic Tutorials.
After you create a rendering device, you can create a viewport and assign it to the device. In short, the viewport determines how the geometry in a 3-D scene is clipped and then represented in the 2-D space of a display screen. (For a conceptual overview about viewports, see Viewports and Clipping.)
Setting up a viewport is a straight-forward process that starts with preparing the viewport parameters in a D3DVIEWPORT7 structure. The Triangle sample sets the viewport parameters to the dimensions of the render target surface:
// Create the viewport DWORD dwRenderWidth = g_rcScreenRect.right - g_rcScreenRect.left; DWORD dwRenderHeight = g_rcScreenRect.bottom - g_rcScreenRect.top; D3DVIEWPORT7 vp = { 0, 0, dwRenderWidth, dwRenderHeight, 0.0f, 1.0f };
Once the viewport structure is prepared, the Triangle application assigns it to the rendering device:
hr = g_pd3dDevice->SetViewport( &vp ); if( FAILED( hr ) ) return hr;
Now that the basic DirectX objects have been created, you can start preparing the subordinate objects required to render scene, which is the topic of Step 3: Initialize the Scene.