Exemple #1
0
        /// <summary>
        /// Creates a new vertex buffer implementation.
        /// </summary>
        /// <param name="declaration">Declaration to use</param>
        /// <param name="vertexCount">Number of vertices</param>
        /// <param name="usage">Resource usage</param>
        /// <returns>
        /// Vertex buffer implementation
        /// </returns>
        public VertexBufferImplementation CreateVertexBufferImplementation(VertexDeclaration declaration, int vertexCount, ResourceUsage usage)
        {
            D3D10VertexBufferImplementation impl = new D3D10VertexBufferImplementation(_renderer, declaration, vertexCount, usage);

            SetGraphicsID(impl);
            return(impl);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new vertex buffer implementation populated with the array of data buffers, one buffer for each vertex element.
        /// These must match up with the defined vertex declaration elements and be of the same number.
        /// </summary>
        /// <param name="declaration">Declaration to use</param>
        /// <param name="usage">Resource usage</param>
        /// <param name="data">DataBuffers to copy from, one for each vertex element. Total stride and size of each element must match the vertex declaration</param>
        /// <returns></returns>
        public VertexBufferImplementation CreateVertexBufferImplementation(VertexDeclaration declaration, ResourceUsage usage, params DataBuffer[] data)
        {
            D3D10VertexBufferImplementation impl = new D3D10VertexBufferImplementation(_renderer, declaration, usage, data);

            SetGraphicsID(impl);
            return(impl);
        }
Exemple #3
0
        private void SetVertexBuffers(VertexBufferBinding[] vertexBuffers, int vbCount)
        {
            //Do some quick validation first
            D3D10Helper.CheckDisposed(_graphicsDevice);
            if (vbCount > _adapter.MaximumVertexStreams || vbCount > vertexBuffers.Length)
            {
                throw new ArgumentOutOfRangeException("vertexBuffers", "Number of vertex buffers to bind to the device exceeds the maximum number of streams.");
            }

            //Clear the currently bound set of buffers
            Array.Clear(_currentVertexBuffers, 0, _currentVertexBufferCount);
            Array.Clear(_vertexBindings, 0, _currentVertexBufferCount);
            _currentVertexBufferCount = 0;

            //Iterate over each buffer, check if it's valid and add it to the bindings array
            for (int i = 0; i < vbCount; i++)
            {
                VertexBufferBinding binding = vertexBuffers[i];
                VertexBuffer        vb      = binding.VertexBuffer;

                //Ensure the buffer exists
                D3D10Helper.CheckDisposed(vb);

                _currentVertexBuffers[_currentVertexBufferCount] = binding;

                D3D10VertexBufferImplementation impl = (D3D10VertexBufferImplementation)vb.Implementation;
                _vertexBindings[_currentVertexBufferCount] = new D3D.VertexBufferBinding(impl.D3DVertexBuffer, vb.VertexDeclaration.VertexStride, binding.VertexOffset);

                _currentVertexBufferCount++;
            }

            //Set the D3D10 bindings to the device
            if (vbCount == 1)
            {
                _graphicsDevice.InputAssembler.SetVertexBuffers(0, _vertexBindings[0]);
            }
            else
            {
                _graphicsDevice.InputAssembler.SetVertexBuffers(0, _vertexBindings);
            }
        }