#region License /* FNA - XNA4 Reimplementation for Desktop Platforms * Copyright 2009-2016 Ethan Lee and the MonoGame Team * * Released under the Microsoft Public License. * See LICENSE for details. */ #endregion namespace Microsoft.Xna.Framework.Graphics { public struct VertexBufferBinding { #region Public Properties /// /// Gets the instance frequency. A value of 0 means no instancing. /// public int InstanceFrequency { get { return instanceFrequency; } } /// /// Gets the vertex buffer. /// public VertexBuffer VertexBuffer { get { return vertexBuffer; } } /// /// Gets the offset in bytes from the beginning of the vertex buffer to the first vertex to use. /// public int VertexOffset { get { return vertexOffset; } } #endregion #region Internal Static Properties /// /// A null vertex buffer binding for unused vertex buffer slots. /// internal static VertexBufferBinding None { get { return none; } } #endregion #region Private Variables private VertexBuffer vertexBuffer; private int vertexOffset; private int instanceFrequency; #endregion #region Private Static Variables private static VertexBufferBinding none = new VertexBufferBinding(null); #endregion #region Public Constructors /// /// Creates an instance of VertexBufferBinding. /// /// The vertex buffer to bind. public VertexBufferBinding(VertexBuffer vertexBuffer) { this.vertexBuffer = vertexBuffer; vertexOffset = 0; instanceFrequency = 0; } /// /// Creates an instance of VertexBufferBinding. /// /// The vertex buffer to bind. /// The offset in bytes to the first vertex to use. public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset) { this.vertexBuffer = vertexBuffer; this.vertexOffset = vertexOffset; instanceFrequency = 0; } /// /// Creates an instance of VertexBufferBinding. /// /// The vertex buffer to bind. /// The offset in bytes to the first vertex to use. /// Number of instances to draw for each draw call. Use 0 if not using instanced drawing. public VertexBufferBinding(VertexBuffer vertexBuffer, int vertexOffset, int instanceFrequency) { this.vertexBuffer = vertexBuffer; this.vertexOffset = vertexOffset; this.instanceFrequency = instanceFrequency; } #endregion #region Implicit Operators public static implicit operator VertexBufferBinding(VertexBuffer buffer) { return new VertexBufferBinding(buffer); } #endregion } }