先定义视口,如D3DVIEWPORT9 g_ViewPort;
然后设置视口参数,如:
g_ViewPort.X = g_ViewPort.Y = 0;
g_ViewPort.Width = g_ViewPort.Height = 100;
g_ViewPort.MinZ = 1.0f;
g_ViewPort.MaxZ = 1000.0f;
最后启用视口,如:
g_pDevice->SetViewport(&g_ViewPort);
g_pDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(123,123,234), 1.0f, 0);
g_pDevice->BeginScene();
g_pDevice->EndScene();