Sdílet prostřednictvím


RenderTarget2D Constructor (GraphicsDevice, Int32, Int32, Int32, SurfaceFormat, MultiSampleType, Int32)

Initializes a new instance of this class.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public RenderTarget2D (
         GraphicsDevice graphicsDevice,
         int width,
         int height,
         int numberLevels,
         SurfaceFormat format,
         MultiSampleType multiSampleType,
         int multiSampleQuality
)

Parameters

  • graphicsDevice
    The graphics device to associate with this render target resource.

  • width
    Width, in pixels, of the render target.

  • height
    Height, in pixels, of the render target.

  • numberLevels
    The number of downsampled surfaces to create when preprocessing the texture. These smaller versions of the texture, known as mip levels, are used when the texture is minified to fit a smaller area than the original texture size. The chain of downsampled surfaces associated with a texture is sometimes called a mipmap chain.

    If this is zero, all texture sublevels down to 1×1 pixels will be generated for hardware that supports mipmapped textures.

  • format
    Surface format of the render target.

  • multiSampleType
    The levels of full-scene multisampling that the device can apply.

  • multiSampleQuality
    The number of quality stops available for a given multisample type.

Exceptions

Exception type Condition
ArgumentException

One of the following conditions is true:

ArgumentNullException graphicsDevice is null.
ArgumentOutOfRangeException width or height is less than or equal to zero. width and height must be greater than zero.
InvalidOperationException Unable to create this RenderTarget2D resource on the graphics device.

Remarks

After a render pass the render target contains the color information of a rendered image.

Render targets represent a linear area of display memory and usually resides in the display memory of the display card. Because of this, objects must be recreated when the device is reset.

See Also

Tasks

How to: Load Resources

Reference

GraphicsDeviceManager.DeviceReset Event
RenderTarget2D Class
RenderTarget2D Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista