Device.CreateDepthStencilSurface(Int32,Int32,DepthFormat,MultiSampleType,Int32,Boolean) Method (Microsoft.DirectX.Direct3D)

Creates a depth stencil resource.

Definition

Visual Basic Public Function CreateDepthStencilSurface( _
    ByVal width As Integer, _
    ByVal height As Integer, _
    ByVal format As DepthFormat, _
    ByVal multiSample As MultiSampleType, _
    ByVal multiSampleQuality As Integer, _
    ByVal discard As Boolean _
) As Surface
C# public Surface CreateDepthStencilSurface(
    int width,
    int height,
    DepthFormat format,
    MultiSampleType multiSample,
    int multiSampleQuality,
    bool discard
);
C++ public:
SurfaceCreateDepthStencilSurface(
    int width,
    int height,
    DepthFormat format,
    MultiSampleType multiSample,
    int multiSampleQuality,
    bool discard
);
JScript public function CreateDepthStencilSurface(
    width : int,
    height : int,
    format : DepthFormat,
    multiSample : MultiSampleType,
    multiSampleQuality : int,
    discard : boolean
) : Surface;

Parameters

width System.Int32
Width of the depth stencil surface in pixels.
height System.Int32
Height of the depth stencil surface in pixels.
format Microsoft.DirectX.Direct3D.DepthFormat
Member of the DepthFormat enumerated type that describes the format of the depth stencil surface. This value must be one of the enumerated depth stencil formats for the current device.
multiSample Microsoft.DirectX.Direct3D.MultiSampleType
Member of the MultiSampleType enumerated type that describes the multisampling buffer type. This value must be one of the supported multisample types. When this surface is passed to the Device.DepthStencilSurface property, its multisample type must be the same as that of the render target set by Device.SetRenderTarget.
multiSampleQuality System.Int32
Quality level. The valid range is between 0 and one less than the level returned by the param_MultiSampleType_multiSampleType parameter of the Manager.CheckDeviceMultiSampleType method. Passing a larger value results in a GraphicsException with an InvalidCall value. The param_Int32_multiSampleQuality values of paired render targets, depth stencil surfaces, and the param_MultiSampleType_multiSample type must all match.
discard System.Boolean
Set to true to enable z-buffer discarding; otherwise false.

If this flag is set, the contents of the depth stencil buffer are invalid after Device.Present is called or when Device.DepthStencilSurface is set with a different depth surface.

This flag's behavior is the same as passing the enumerated value PresentFlag.DiscardDepthStencil to the Device.Present method.

Return Value

Microsoft.DirectX.Direct3D.Surface
A Surface that represents the created depth stencil surface resource.

Remarks

The memory class of the depth stencil buffer is always Default.

Exceptions

NotAvailableException

The current device does not support the queried multisample type.

InvalidCallException

The method call is invalid. For example, a parameter might contain an invalid value.

OutOfVideoMemoryException

Microsoft Direct3D does not have enough display memory to perform the operation.

OutOfMemoryExceptionLeave Site

Direct3D could not allocate sufficient memory to complete the call.