次の方法で共有


DynamicVertexBuffer Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a list of 3D vertices to be streamed to the graphics device. Use DynamicVertexBufferfor dynamic vertex arrays and VertexBuffer for non-dynamic vertex arrays.

Inheritance Hierarchy

System.Object
  Microsoft.Xna.Framework.Graphics.GraphicsResource
    Microsoft.Xna.Framework.Graphics.VertexBuffer
      Microsoft.Xna.Framework.Graphics.DynamicVertexBuffer

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

Syntax

'Declaration
Public Class DynamicVertexBuffer _
    Inherits VertexBuffer
public class DynamicVertexBuffer : VertexBuffer

The DynamicVertexBuffer type exposes the following members.

Constructors

  Name Description
Public method DynamicVertexBuffer(GraphicsDevice, VertexDeclaration, Int32, BufferUsage) Creates an instance of this object.
Public method DynamicVertexBuffer(GraphicsDevice, Type, Int32, BufferUsage) Creates a new instance of this object.

Top

Properties

  Name Description
Public property BufferUsage Gets the state of the related BufferUsage enumeration. (Inherited from VertexBuffer.)
Public property IsDisposed Gets a value that indicates whether the object is disposed. (Inherited from GraphicsResource.)
Public property VertexCount Gets the number of vertices. (Inherited from VertexBuffer.)
Public property VertexDeclaration Defines per-vertex data in a buffer. (Inherited from VertexBuffer.)

Top

Methods

  Name Description
Public method Dispose() Immediately releases the unmanaged resources used by this object. (Inherited from GraphicsResource.)
Protected method Dispose(Boolean) Immediately releases the unmanaged resources used by this object. (Inherited from GraphicsResource.)
Protected method Finalize Allows this object to attempt to free resources and perform other cleanup operations before garbage collection reclaims the object. (Inherited from GraphicsResource.)
Public method SetData<T>(array<T[]) Sets vertex buffer data. (Inherited from VertexBuffer.)
Public method SetData<T>(array<T[], Int32, Int32) Sets vertex buffer data, specifying the start index and number of elements. (Inherited from VertexBuffer.)
Public method SetData<T>(array<T[], Int32, Int32, SetDataOptions) Sets dynamic vertex buffer data, specifying the start index, number of elements and options.
Public method SetData<T>(Int32, array<T[], Int32, Int32, Int32) Sets vertex buffer data, specifying the offset, start index, number of elements, and the vertex stride. (Inherited from VertexBuffer.)
Public method SetData<T>(Int32, array<T[], Int32, Int32, Int32, SetDataOptions) Sets dynamic vertex buffer data, specifying the offset, start index, number of elements and vertex stride.

Top

Remarks

In situations where your code frequently modifies a vertex buffer, it is recommended that the buffer be instantiated or derived from DynamicVertexBuffer instead of the VertexBuffer class. DynamicVertexBuffer is optimized for frequent vertex data modification. However, to fully maximize the benefits of this class, your data must be restored after any occurrence of a ContentLost event. This event occurs whenever the related graphics device is lost. After resetting the graphics device and restoring any static resources, the ContentLost event handler is then called. Calling SetData inside this handler restores any dynamic resource data.

You can declare the event handler after constructing your dynamic vertex buffer. For example, the following code sample first constructs a dynamic vertex buffer (called vertexBuffer), declares a ContentLost event handler (called vertexBuffer_ContentLost). The final step initializes the data with a call to SetData. This is necessary for correct restoration of any existing particles after a lost device event.

vertexBuffer = new DynamicVertexBuffer(GraphicsDevice, size, BufferUsage.Points);
vertexBuffer.ContentLost += new EventHandler(vertexBuffer_ContentLost);
vertexBuffer.SetData(particles);

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.