本文整理汇总了C#中DeviceContext.DrawAuto方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext.DrawAuto方法的具体用法?C# DeviceContext.DrawAuto怎么用?C# DeviceContext.DrawAuto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceContext
的用法示例。
在下文中一共展示了DeviceContext.DrawAuto方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
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();
}
}