Export (0) Print
Expand All

Displays, Client Bounds, Viewports, and Back Buffers

This article describes the relationships between the display, client, viewport, and back buffer size properties. Bb203889.WinVsXboxDisplay(en-US,XNAGameStudio.20).png

Figure 1.  In this diagram, the Windows display is shown with a game that is not in full-screen mode to illustrate the difference between the DisplayMode and ClientBounds dimensions. Note also that the same back buffer may render differently on an Xbox 360 console compared to a Windows display because the outer 10 to 20 percent of the Xbox 360 back buffer is not "title safe" and may not be visible.

DisplayMode Width and Height

The DisplayMode Width and Height properties correspond to the bounds of the display. The display bounds are different than the bounds of the game window, which can be obtained from the ClientBounds dimensions.

When going into full-screen mode on Windows, it is useful to know the display mode width and height so the back buffer dimensions can be set to match the resolution of the display. If the back buffer dimensions are not changed to match the display mode dimensions, the resolution would change when going into full screen mode.

Xbox 360 games should display all text and menu items critical to game play within the inner 80 percent of the x and y resolution for all display modes. This is known as the title safe region.

ClientBounds Width and Height

The ClientBounds Width and Height properties correspond to the bounds of the game window, which may be less than the bounds of the display if the game is not full screen. ClientBounds.X and ClientBounds.Y correspond to the upper-left coordinate of the game window relative to the display mode width and height. On Xbox 360, the ClientBounds Width and Height properties are always equal to the DisplayMode Width and Height, and ClientBounds.X and ClientBounds.Y are always (0, 0).

Viewport Width and Height

The Viewport Width and Height properties correspond to the current viewport dimensions, which can be thought of as the view space width and height. These values are commonly used by methods to create projection matrices, such as CreatePerspectiveFieldOfView. When creating a camera class, you would set the Viewport width and height to correspond to the size of the camera viewport.

The dimensions of a viewport default to the dimensions of the render target, but may be a subset of the render target. For example, you might render multiple viewports to a single render target to create a split screen game.

The Viewport dimensions do not correspond to the size of the game window (see ClientBounds for this information) or the display (see DisplayMode for this information).

Back Buffer Width and Height

The back buffer is a specific render target that has been set to be the next render target presented when GraphicsDevice.Present is called. To obtain the dimensions of the back buffer, use the GraphicsDevice.PresentationParameters BackBufferWidth and BackBufferHeight properties.

On Windows, the back buffer is created to match the dimensions of the ClientBounds by default. For Xbox 360 game projects, the back buffer is created with the dimensions that have been specified by the user.

When going into full-screen mode on Windows, it is often desirable to set the back buffer dimensions to match the DisplayMode dimensions so that the game ("display") resolution does not change when going into full-screen mode.

The graphics back buffer created for an Xbox 360 game project is not necessarily the same size as the final resolution on the television connected to the Xbox 360. The Xbox 360 automatically scales output to the television resolution selected by the user in the System Blade. If the aspect ratio of the back buffer is different than the aspect ratio of the television display mode, the Xbox 360 will automatically add "black bars" (letterboxing) if the user's display is not widescreen.

An error occurs if a graphics back buffer, with a resolution of 1920x1080 (e.g. 1080p), is created and displayed on a device with 480i resolution (e.g. a standard TV). However, resolutions for other modes (such as: 480p, 720p, 1080i) are permitted.

Community Additions

ADD
Show:
© 2015 Microsoft