Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VertexBufferBinding"/> struct.
        /// </summary>
        /// <param name="vertexStride">Jump size to the next element. if -1, it gets auto-discovered from the vertexDeclaration</param>
        /// <param name="vertexOffset">Offset (in Vertex ElementCount) from the beginning of the buffer to the first vertex to use.</param>
        public VertexBufferBinding(Buffer vertexBuffer, VertexDeclaration vertexDeclaration, int vertexCount, int vertexStride = -1, int vertexOffset = 0) : this()
        {
            if (vertexBuffer == null)
            {
                throw new ArgumentNullException("vertexBuffer");
            }
            if (vertexDeclaration == null)
            {
                throw new ArgumentNullException("vertexDeclaration");
            }

            Buffer      = vertexBuffer;
            Stride      = vertexStride != -1 ? vertexStride : vertexDeclaration.VertexStride;
            Offset      = vertexOffset;
            Count       = vertexCount;
            Declaration = vertexDeclaration;

            unchecked
            {
                hashCode = Buffer.GetHashCode();
                hashCode = (hashCode * 397) ^ Offset;
                hashCode = (hashCode * 397) ^ Stride;
                hashCode = (hashCode * 397) ^ Count;
                hashCode = (hashCode * 397) ^ Declaration.GetHashCode();
            }
        }