Preparing to Use a Viewport

To set up a viewport in Direct3D

  1. Create a viewport object.

    Creating the viewport causes Direct3D to allocate internal data structures that contain the viewport's properties. For more information, see Creating a Viewport.

  2. Add the viewport to a device.

    This creates an association between a viewport and a device; the device adds the viewport to an internal list of viewports. You can switch the current viewport by calling the IDirect3DDevice3::NextViewport method for that device. For more information about this step, see Adding a Viewport to a Device.

  3. Set the viewport properties.

    After adding the viewport to a device, you can set its properties. The viewport properties control how Direct3D clips objects from a scene and determine the aspect ratio of the scene rendered to the target surface.

When you're finished working with the viewport, you can delete it from the device's viewport list. For more information, see Deleting a Viewport.