Esempio n. 1
0
        public void Render()
        {
            _dxDevice.InputAssembler.SetInputLayout(_inputLayout);

/*
 *          _viewVariable.SetMatrix(view);
 *          _projectionVariable.SetMatrix(projection);
 */

            _effectPass.Apply();


            _dxDevice.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            _dxDevice.InputAssembler.SetIndexBuffer(_indexBuffer, Format.R16_UInt, 0);                   // R16_UInt = Size of one index , here is short = 16
            _dxDevice.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_vertexBuffer, 32, 0)); // 32  = Size of one vertex;
            _dxDevice.DrawIndexed(36, 0, 0);
        }
        public void Render(DxCamera camera)
        {
            if (_vertexBuffer == null || _vertexCount == 0)
            {
                return;
            }

            _worldVar.SetMatrix(Matrix.Scaling(Scale, -Scale, Scale));
            _eyePosWVar.Set(camera.Eye);
            _viewProjVar.SetMatrix(camera.View * camera.Projection);
            _fillColorVar.Set(_fillColor);

            _resVar.Set(new Vector2(_xRes, _yRes));
            _focalLengthDepthVar.Set(_focalLengthDepth);
            _focalLengthImageVar.Set(_focalLengthImage);
            _depthToRgbVar.SetMatrix(_depthToRgb);

            if (_headlight)
            {
                _light.Position  = camera.Eye;
                _light.Direction = camera.At - camera.Eye;
            }
            _light.SetEffectVariable(_lightVariable);

            _depthMapVar.SetResource(_depthMapBufferRV);
            _imageMapVar.SetResource(_imageTextureRV);

            _dxDevice.InputAssembler.SetInputLayout(_inputLayout);
            _dxDevice.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            _dxDevice.InputAssembler.SetIndexBuffer(_indexBuffer, Format.R32_UInt, 0);
            _dxDevice.InputAssembler.SetVertexBuffers(0,
                                                      new VertexBufferBinding(_vertexBuffer, PointVertex.SizeOf, 0));

            for (int p = 0; p < _renderTech.Description.PassCount; p++)
            {
                _renderTech.GetPassByIndex(p).Apply();
                _dxDevice.DrawIndexed(_indexCount, 0, 0);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Draws indexed geometry.
        /// </summary>
        /// <param name="primType">Type of the primitives to draw.</param>
        /// <param name="indexCount">Number of indices to draw.</param>
        /// <param name="startIndex">Starting index in the index buffer at which to read vertex indices from.</param>
        /// <param name="baseVertex">Offset to add to each vertex index in the index buffer.</param>
        public override void DrawIndexed(PrimitiveType primType, int indexCount, int startIndex, int baseVertex)
        {
            D3D10Helper.CheckDisposed(_graphicsDevice);
            if (indexCount <= 0)
            {
                throw new ArgumentOutOfRangeException("indexCount", "Index count must be greater than zero.");
            }

            if (_currentIndexBuffer == null)
            {
                throw new ArgumentNullException("DrawIndexed requires a valid index buffer.");
            }
            else
            {
                D3D10Helper.CheckDisposed(_currentIndexBuffer);
            }

            //Send any remaining texture/sampler changes to the device.
            FlushStates();

            _graphicsDevice.InputAssembler.SetInputLayout(_currentPass.InputLayoutMap.GetOrCreateLayout(_currentVertexBuffers, _currentVertexBufferCount));
            _graphicsDevice.InputAssembler.SetPrimitiveTopology(D3D10Helper.ToD3DPrimitiveType(primType));
            _graphicsDevice.DrawIndexed(indexCount, startIndex, baseVertex);
        }
Esempio n. 4
0
        public virtual void Render(Device device, ShaderHelper shaderHelper)
        {
            if (vertexBuffer != null && Topology != PrimitiveTopology.Undefined)
            {
                device.InputAssembler.SetInputLayout(vertexLayout);
                device.InputAssembler.SetPrimitiveTopology(Topology);

                device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, Marshal.SizeOf(typeof(Vertex)), 0));
                if (indexBuffer != null)
                    device.InputAssembler.SetIndexBuffer(indexBuffer, Format.R32_UInt, 0);

                shaderHelper.ConstantBufferSet.World = World;
                shaderHelper.ConstantBufferSet.LocalRotation = RotationMatrix;
                shaderHelper.ConstantBufferSet.TextureIndex = TextureIndex;
                shaderHelper.ApplyEffects();

                if (indexBuffer != null)
                    device.DrawIndexed(Vertices.NumElements, 0, 0);
                else
                {
                    device.Draw(Vertices.NumElements, 0);
                }
            }
        }
 protected override void Draw()
 {
     Device.DrawIndexed(IndexCount, StartIndex, BaseVertex);
 }