?/TD> |
Microsoft DirectX 9.0 |
The only requirement for configuring the viewport parameters for a rendering device is to set the viewport's clipping volume. To do this, you initialize and set clipping values for the clipping volume and for the render-target surface. Viewports are commonly set up to render to the full area of the render-target surface, but this isn't a requirement.
You can use the following settings for the members of the D3DVIEWPORT9 structure to achieve this in C++.
D3DVIEWPORT9 viewData = { 0, 0, width, height, 0.0f, 1.0f };
After setting values in the D3DVIEWPORT9 structure, apply the viewport parameters to the device by calling its IDirect3DDevice9::SetViewport method. The following code example shows what this call might look like.
HRESULT hr; hr = pd3dDevice->SetViewport(&viewData); if(FAILED(hr)) return hr;
If the call succeeds, the viewport parameters are set and will take effect the next time a rendering method is called. To make changes to the viewport parameters, just update the values in the D3DVIEWPORT9 structure and call IDirect3DDevice9::SetViewport again.