Updating the Viewport

The UpdateViewport function updates the viewport in response to a change in window size. This ensures that we render at a resolution that matches the client area of the target window.

static HRESULT 
UpdateViewport(void) 
{ 
    D3DVIEWPORT d3dViewport; 
 
    ASSERT(NULL != lpd3dViewport); 
 
    ZeroMemory(&d3dViewport, sizeof(d3dViewport)); 
    d3dViewport.dwSize   = sizeof(d3dViewport); 
    d3dViewport.dwX      = 0; 
    d3dViewport.dwY      = 0; 
    d3dViewport.dwWidth  = (DWORD)rSrcRect.right; 
    d3dViewport.dwHeight = (DWORD)rSrcRect.bottom; 
    d3dViewport.dvScaleX = D3DVAL((float)d3dViewport.dwWidth / 2.0); 
    d3dViewport.dvScaleY = D3DVAL((float)d3dViewport.dwHeight / 2.0); 
    d3dViewport.dvMaxX   = D3DVAL(1.0); 
    d3dViewport.dvMaxY   = D3DVAL(1.0); 
    return lpd3dViewport->lpVtbl->SetViewport(lpd3dViewport, 
        &d3dViewport); 
}