Пример #1
0
        /// <summary>
        /// Creates an instance of this object.
        /// </summary>
        /// <param name="vertexBuffer">The vertex buffer</param>
        /// <param name="vertexDeclaration">The vertex declaration.</param>
        /// <param name="vertexCount">The vertex count.</param>
        /// <param name="vertexStride">The vertex stride.</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 = 0, int vertexOffset = 0) : this()
        {
            if (vertexBuffer == null)
            {
                throw new ArgumentNullException("vertexBuffer");
            }
            if (vertexDeclaration == null)
            {
                throw new ArgumentNullException("vertexDeclaration");
            }

            Buffer      = vertexBuffer;
            Stride      = vertexStride != 0 ? 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();
            }
        }