コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VertexBufferLayout" /> struct.
        /// </summary>
        /// <param name="slot">The slot to bind this vertex buffer to.</param>
        /// <param name="structType">Type of a structure that is using <see cref="VertexElementAttribute" />.</param>
        /// <param name="instanceCount">Specify the instancing count. Set to 0 for no instancing.</param>
        /// <returns>A new instance of <see cref="VertexBufferLayout"/>.</returns>
        public static VertexBufferLayout New(int slot, Type structType, int instanceCount = 0)
        {
            var vertexElements = VertexElement.FromType(structType);

            if (vertexElements == null)
            {
                throw new ArgumentException(string.Format("Unable to calculate VertexElements from Type [{0}]. This type is not using VertexElementAttribute.", structType.Name), "structType");
            }

            return(New(slot, vertexElements, instanceCount));
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrimitiveBatch{T}" /> class.
        /// </summary>
        /// <param name="graphicsDevice">The device.</param>
        /// <param name="maxIndices">The max indices.</param>
        /// <param name="maxVertices">The max vertices.</param>
        public PrimitiveBatch(GraphicsDevice graphicsDevice, int maxIndices = DefaultBatchSize * 3, int maxVertices = DefaultBatchSize)
            : base(graphicsDevice, maxIndices, maxVertices, Utilities.SizeOf <T>())
        {
            var vertexElements = VertexElement.FromType <T>();

            // If the type has some VertexElement description, we can use them directly to setup the vertex input layout.
            if (vertexElements != null)
            {
                vertexInputLayout = VertexInputLayout.New(0, vertexElements);
            }
        }