コード例 #1
0
        /// <summary>
        /// Function to set a vertex buffer binding for the draw call.
        /// </summary>
        /// <param name="layout">The input layout to use.</param>
        /// <param name="binding">The vertex buffer binding to set.</param>
        /// <param name="slot">[Optional] The slot for the binding.</param>
        /// <returns>The fluent builder interface.</returns>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="layout"/> parameter is <b>null</b>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="slot"/> parameter is less than 0, or greater than/equal to <see cref="GorgonVertexBufferBindings.MaximumVertexBufferCount"/>.</exception>
        public TB VertexBuffer(GorgonInputLayout layout, GorgonVertexBufferBinding binding, int slot = 0)
        {
            if ((slot < 0) || (slot >= GorgonVertexBufferBindings.MaximumVertexBufferCount))
            {
                throw new ArgumentOutOfRangeException(nameof(slot), string.Format(Resources.GORGFX_ERR_INVALID_VERTEXBUFFER_SLOT, GorgonVertexBufferBindings.MaximumVertexBufferCount));
            }

            if (DrawCall.D3DState.VertexBuffers == null)
            {
                DrawCall.D3DState.VertexBuffers = new GorgonVertexBufferBindings();
            }

            DrawCall.D3DState.VertexBuffers[slot]       = binding;
            DrawCall.D3DState.VertexBuffers.InputLayout = layout ?? throw new ArgumentNullException(nameof(layout));
            return((TB)this);
        }
コード例 #2
0
 /// <summary>
 /// Function to convert a GorgonVertexBufferBinding to a D3D11 vertex buffer binding.
 /// </summary>
 /// <param name="binding">The binding to convert.</param>
 /// <returns>The D3D11 vertex buffer binding.</returns>
 public static D3D11.VertexBufferBinding ToVertexBufferBinding(this GorgonVertexBufferBinding binding) => new D3D11.VertexBufferBinding(binding.VertexBuffer?.Native, binding.Stride, binding.Offset);