Bagikan melalui


OcclusionQuery.PixelCount Property

Gets the number of visible pixels.

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

Syntax

public int PixelCount { get; }

Property Value

Number of visible pixels. Zero indicates full occlusion, which means the pixels are not visible from the current camera position.

Exceptions

Exception type Condition
InvalidOperationException The query data is not yet available. Use the IsComplete property to determine if the data is available before attempting to retrieve it.

Remarks

The number of non-occluded pixels (indicated by PixelCount) can differ based on the platform.

For Xbox 360 games, PixelCount represents the number of pixels modified by drawing. This includes GraphicsDevice.Clear calls and any drawing associated with sprite batches.

For Windows games, PixelCount represents the number of pixels that passed the depth and stencil tests. This does not include sprite batch drawing (because the depth test is turned off) or calls to GraphicsDevice.Clear.

To achieve consistent results across all platforms, use occlusion queries only when the depth buffer is enabled. In addition, avoid calling Clear or changing the assigned render target inside an occlusion query begin/end block.

See Also

Reference

OcclusionQuery Class
OcclusionQuery Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP