/
DynamicVertexBuffer.cs
41 lines (33 loc) · 1.65 KB
/
DynamicVertexBuffer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// MonoGame - Copyright (C) MonoGame Foundation, Inc
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using MonoGame.Framework.Utilities;
namespace Microsoft.Xna.Framework.Graphics
{
public class DynamicVertexBuffer : VertexBuffer
{
/// <summary>
/// Special offset used internally by GraphicsDevice.DrawUserXXX() methods.
/// </summary>
internal int UserOffset;
public bool IsContentLost { get { return false; } }
public DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage bufferUsage)
: base(graphicsDevice, vertexDeclaration, vertexCount, bufferUsage, true)
{
}
public DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type type, int vertexCount, BufferUsage bufferUsage)
: base(graphicsDevice, VertexDeclaration.FromType(type), vertexCount, bufferUsage, true)
{
}
public void SetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride, SetDataOptions options) where T : struct
{
base.SetDataInternal<T>(offsetInBytes, data, startIndex, elementCount, vertexStride, options);
}
public void SetData<T>(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
{
var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
base.SetDataInternal<T>(0, data, startIndex, elementCount, elementSizeInBytes, options);
}
}
}