Considerations for Various Vertex Types

If you are using D3DVERTEX or D3DLVERTEX vertices—that is, if Direct3D is performing the transformations—you might want to set the last six members of this structure as follows:

    dvClipX = -1.0f;
    dvClipY =  1.0f;
    dvClipWidth = 2.0f;
    dvClipHeight = 2.0f;
    dvMinZ = 0.0f;
    dvMaxZ = 1.0f;
 

Note that setting the viewport values as shown in the preceding example doesn't account for the viewport aspect ratio. Although it's not uncommon to use viewport parameters for aspect ratio scaling, the projection matrix is a more accurate, more flexible, and cleaner platform for the task. For more information about accounting for the viewport aspect ratio in the projection matrix, see What Is the Projection Transformation?

If you are using D3DTLVERTEX vertices—that is, if your application is calculating the transformations and lighting—you can set up the clip space however is best for your application. If the x- and y-coordinates in your data already match pixels, you could set the last six members of D3DVIEWPORT2 as follows:

    dvClipX = 0;
    dvClipY = 0;
    dvClipWidth = dwWidth;
    dvClipHeight = dwHeight;
    dvMinZ = 0.0f;
    dvMaxZ = 1.0f;
 

You can use the rectangle defined by the dwX, dwY, dwWidth, and dwHeight members of the D3DVIEWPORT2 structure to clip your geometry. Although the clipping members (their names begin with "dvClip") in D3DVIEWPORT2 are ignored when you use D3DTLVERTEX vertices, the system still validates them, so you must provide reasonable values for them. If you don't need this clipping, you can specify D3DDP_DONOTCLIP in your calls to IDirect3DDevice3::DrawPrimitive or IDirect3DDevice3::DrawIndexedPrimitive.