Skip to content

Commit

Permalink
Merge pull request #8278 from Maniekko/docs/vertexbuffer
Browse files Browse the repository at this point in the history
[Documentation]: Add XML documentation to the VertexBuffer class
  • Loading branch information
SimonDarksideJ committed Apr 16, 2024
2 parents 40452a4 + 392ad06 commit d5af7a9
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,36 @@
using MonoGame.Framework.Utilities;

namespace Microsoft.Xna.Framework.Graphics
{
{
/// <summary>
/// Represents a list of 3D vertices to be streamed to the graphics device.
/// </summary>
public partial class VertexBuffer : GraphicsResource
{
private readonly bool _isDynamic;

public int VertexCount { get; private set; }
public VertexDeclaration VertexDeclaration { get; private set; }

/// <summary>
/// Gets the number of vertices.
/// </summary>
public int VertexCount { get; private set; }
/// <summary>
/// Defines per-vertex data in a buffer.
/// </summary>
public VertexDeclaration VertexDeclaration { get; private set; }
/// <summary>
/// A usage hint for optimizing memory placement of this buffer.
/// </summary>
public BufferUsage BufferUsage { get; private set; }


/// <summary>
/// Creates a new instance of <see cref="VertexBuffer"/>
/// </summary>
/// <param name="graphicsDevice">The graphics device.</param>
/// <param name="vertexDeclaration">The vertex declaration, which describes per-vertex data.</param>
/// <param name="vertexCount">The number of vertices.</param>
/// <param name="bufferUsage">Behavior options.</param>
/// <param name="dynamic">Whether this buffer is dynmic.</param>
/// <exception cref="ArgumentNullException"><paramref name="graphicsDevice"/> is <see langword="null"/></exception>
protected VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage bufferUsage, bool dynamic)
{
if (graphicsDevice == null)
Expand All @@ -34,13 +55,19 @@ protected VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDe

PlatformConstruct();
}


/// <inheritdoc cref="VertexBuffer(GraphicsDevice, VertexDeclaration, int, BufferUsage, bool)"/>
public VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage bufferUsage) :
this(graphicsDevice, vertexDeclaration, vertexCount, bufferUsage, false)
{
}

public VertexBuffer(GraphicsDevice graphicsDevice, Type type, int vertexCount, BufferUsage bufferUsage) :
}

/// <inheritdoc cref="VertexBuffer(GraphicsDevice, VertexDeclaration, int, BufferUsage, bool)"/>
/// <param name="graphicsDevice"/>
/// <param name="type">The data type.</param>
/// <param name="vertexCount"/>
/// <param name="bufferUsage"/>
public VertexBuffer(GraphicsDevice graphicsDevice, Type type, int vertexCount, BufferUsage bufferUsage) :
this(graphicsDevice, VertexDeclaration.FromType(type), vertexCount, bufferUsage, false)
{
}
Expand Down Expand Up @@ -98,12 +125,14 @@ public void GetData<T> (int offsetInBytes, T[] data, int startIndex, int element

PlatformGetData<T>(offsetInBytes, data, startIndex, elementCount, vertexStride);
}


/// <inheritdoc cref="GetData{T}(int, T[], int, int, int)"/>
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
this.GetData<T>(0, data, startIndex, elementCount, 0);
}
}

/// <inheritdoc cref="GetData{T}(int, T[], int, int, int)"/>
public void GetData<T>(T[] data) where T : struct
{
var elementSizeInByte = ReflectionHelpers.SizeOf<T>.Get();
Expand Down Expand Up @@ -188,7 +217,8 @@ public void SetData<T>(T[] data) where T : struct
var elementSizeInBytes = ReflectionHelpers.SizeOf<T>.Get();
SetDataInternal<T>(0, data, 0, data.Length, elementSizeInBytes, SetDataOptions.None);
}


/// <summary/>
protected void SetDataInternal<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride, SetDataOptions options) where T : struct
{
if (data == null)
Expand Down

0 comments on commit d5af7a9

Please sign in to comment.