/// <summary> /// /// </summary> /// <param name="vertexCount"></param> /// <param name="vertexFirstIndex"></param> public void DrawAuto() { lock (deviceContext) { ApplyGpuState(); //deviceContext.InputAssembler.PrimitiveTopology = Converter.Convert( primitive ); deviceContext.DrawAuto(); } }
public void BindComponentsPSStage(DeviceContext deviceContext) { deviceContext.StreamOutput.SetTargets(null); deviceContext.VertexShader.Set(colorVertexShader); deviceContext.PixelShader.Set(colorPixelShader); deviceContext.InputAssembler.InputLayout = colorInputLayout; deviceContext.DrawAuto(); }
public void DrawPS(DeviceContext deviceContext, Matrix view, Matrix proj, Matrix transform) { BindComponentsPSStage(deviceContext); var viewProj = transform * view * proj; deviceContext.UpdateSubresource(ref viewProj, constantBufferColor, 0); deviceContext.VertexShader.SetConstantBuffer(0, constantBufferColor); deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineList; deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(soBuffer, Utilities.SizeOf <VertexPositionColor>(), 0)); deviceContext.DrawAuto(); }
public virtual void Draw(DeviceContext ctx) { ctx.DrawAuto(); }
public void Draw(DeviceContext dc, CameraBase camera) { var vp = camera.ViewProj; // set shader variables _fx.SetViewProj(vp); _fx.SetGameTime(_gameTime); _fx.SetTimeStep(_timeStep); _fx.SetEyePosW(EyePosW); _fx.SetEmitPosW(EmitPosW); _fx.SetEmitDirW(EmitDirW); _fx.SetTexArray(_texArraySRV); _fx.SetRandomTex(_randomTexSRV); dc.InputAssembler.InputLayout = InputLayouts.Particle; dc.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList; var stride = Particle.Stride; const int offset = 0; // bind the input vertex buffer for the stream-out technique // use the _initVB when _firstRun = true dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_firstRun ? _initVB : _drawVB, stride, offset)); // bind the stream-out vertex buffer dc.StreamOutput.SetTargets(new StreamOutputBufferBinding(_streamOutVB, offset)); // draw the particles using the stream-out technique, which will update the particles positions // and output the resulting particles to the stream-out buffer var techDesc = _fx.StreamOutTech.Description; for (int p = 0; p < techDesc.PassCount; p++) { _fx.StreamOutTech.GetPassByIndex(p).Apply(dc); if (_firstRun) { dc.Draw(1, 0); _firstRun = false; } else { // the _drawVB buffer was populated by the Stream-out technique, so we don't // know how many vertices are contained within it. Direct3D keeps track of this // internally, however, and we can use DrawAuto to draw everything in the buffer. dc.DrawAuto(); } } // Disable stream-out dc.StreamOutput.SetTargets(null); // ping-pong the stream-out and draw buffers, since we will now want to draw the vertices // populated into the buffer that was bound to stream-out var temp = _drawVB; _drawVB = _streamOutVB; _streamOutVB = temp; // draw the particles using the draw technique that will transform the points to lines/quads dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_drawVB, stride, offset)); techDesc = _fx.DrawTech.Description; for (var p = 0; p < techDesc.PassCount; p++) { _fx.DrawTech.GetPassByIndex(p).Apply(dc); dc.DrawAuto(); } }
public void Draw(DeviceContext dc, CameraBase camera) { var vp = camera.ViewProj; // set shader variables _fx.SetViewProj(vp); _fx.SetGameTime(_gameTime); _fx.SetTimeStep(_timeStep); _fx.SetEyePosW(EyePosW); _fx.SetEmitPosW(EmitPosW); _fx.SetEmitDirW(EmitDirW); _fx.SetTexArray(_texArraySRV); _fx.SetRandomTex(_randomTexSRV); dc.InputAssembler.InputLayout = InputLayouts.Particle; dc.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList; var stride = Particle.Stride; const int offset = 0; // bind the input vertex buffer for the stream-out technique // use the _initVB when _firstRun = true dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_firstRun ? _initVB : _drawVB, stride, offset)); // bind the stream-out vertex buffer dc.StreamOutput.SetTargets(new StreamOutputBufferBinding(_streamOutVB, offset)); // draw the particles using the stream-out technique, which will update the particles positions // and output the resulting particles to the stream-out buffer var techDesc = _fx.StreamOutTech.Description; for (int p = 0; p < techDesc.PassCount; p++) { _fx.StreamOutTech.GetPassByIndex(p).Apply(dc); if (_firstRun) { dc.Draw(1, 0); _firstRun = false; } else { // the _drawVB buffer was populated by the Stream-out technique, so we don't // know how many vertices are contained within it. Direct3D keeps track of this // internally, however, and we can use DrawAuto to draw everything in the buffer. dc.DrawAuto(); } } // Disable stream-out dc.StreamOutput.SetTargets(null); // ping-pong the stream-out and draw buffers, since we will now want to draw the vertices // populated into the buffer that was bound to stream-out var temp = _drawVB; _drawVB = _streamOutVB; _streamOutVB = temp; // draw the particles using the draw technique that will transform the points to lines/quads dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_drawVB, stride, offset)); techDesc = _fx.DrawTech.Description; for (var p = 0; p < techDesc.PassCount; p++) { _fx.DrawTech.GetPassByIndex(p).Apply(dc); dc.DrawAuto(); } }