本文整理汇总了C#中DeviceContext.DrawIndexed方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext.DrawIndexed方法的具体用法?C# DeviceContext.DrawIndexed怎么用?C# DeviceContext.DrawIndexed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceContext
的用法示例。
在下文中一共展示了DeviceContext.DrawIndexed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(DeviceContext deviceContext, int indexCount, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
{
UpdateMatrixBuffer(deviceContext, ConstantMatrixBuffer, worldMatrix, viewMatrix, projectionMatrix);
deviceContext.VertexShader.SetConstantBuffer(0, ConstantMatrixBuffer);
deviceContext.InputAssembler.InputLayout = Layout;
deviceContext.VertexShader.Set(VertexShader);
deviceContext.PixelShader.Set(PixelShader);
deviceContext.DrawIndexed(indexCount, 0, 0);
}
示例2: Draw
public void Draw(float elapsedTime, Matrix view, Matrix projection, Matrix world, DeviceContext context)
{
basicEffect.World = world;
basicEffect.View = view;
basicEffect.Projection = projection;
basicEffect.Apply(context);
context.InputAssembler.SetVertexBuffers(0,
new VertexBufferBinding(vertices, VertexPositionNormalTexture.Size, 0));
context.InputAssembler.SetIndexBuffer(indices, Format.R32_UInt, 0);
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
context.DrawIndexed(indexCount, 0, 0);
}
示例3: Draw
public void Draw(DeviceContext context)
{
foreach (var mesh in _meshes)
{
if (mesh.PrimitiveTopology != PrimitiveTopology.TriangleList)
continue; // TODO
context.InputAssembler.InputLayout = mesh.InputLayout;
context.InputAssembler.PrimitiveTopology = mesh.PrimitiveTopology;
context.InputAssembler.SetVertexBuffers(0,
new VertexBufferBinding(mesh.VertexBuffer, 0, mesh.VertexSize));
context.InputAssembler.SetIndexBuffer(mesh.IndexBuffer, Format.R32_UInt, 0);
context.PixelShader.SetShaderResources(0, mesh.DiffuseTextureView);
context.DrawIndexed(mesh.IndexCount, 0, 0);
}
}
示例4: Render
//Go through the meshes and render them
public void Render(DeviceContext context)
{
if (!m_inputLayoutSet)
throw new Exception("Model::Render(): input layout has not be specified, you must call SetInputLayout() before calling Render()");
foreach (ModelMesh mesh in m_meshes)
{
//set mesh specific data
context.InputAssembler.InputLayout = mesh.InputLayout;
context.InputAssembler.PrimitiveTopology = mesh.PrimitiveTopology;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(mesh.VertexBuffer, mesh.VertexSize, 0));
context.InputAssembler.SetIndexBuffer(mesh.IndexBuffer, Format.R32_UInt, 0);
context.PixelShader.SetShaderResource(0, mesh.DiffuseTextureView);
//draw
context.DrawIndexed(mesh.IndexCount, 0, 0);
}
}
示例5: Draw
public void Draw(DeviceContext dc, CameraBase camera) {
var eyePos = camera.Position;
var t = Matrix.Translation(eyePos);
var wvp = t * camera.ViewProj;
Effects.SkyFX.SetWorldViewProj(wvp);
Effects.SkyFX.SetCubeMap(_cubeMapSRV);
var stride = Marshal.SizeOf(typeof(Vector3));
const int Offset = 0;
dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_vb, stride, Offset));
dc.InputAssembler.SetIndexBuffer(_ib, Format.R32_UInt, 0);
dc.InputAssembler.InputLayout = InputLayouts.Pos;
dc.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
var tech = Effects.SkyFX.SkyTech;
for (var p = 0; p < tech.Description.PassCount; p++) {
var pass = tech.GetPassByIndex(p);
pass.Apply(dc);
dc.DrawIndexed(_indexCount, 0, 0);
}
}
示例6: Draw
public void Draw(DeviceContext Context)
{
Context.InputAssembler.PrimitiveTopology = MaterialShader.Topology;
if (this is SkinnedMeshPrimitive)
Context.InputAssembler.InputLayout = MaterialShader.SkinnedMeshInputLayout;
else
Context.InputAssembler.InputLayout = MaterialShader.StaticMeshInputLayout;
Context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(GeometryData.VertexBuffer, GeometryData.VertexStride, 0));
Context.InputAssembler.SetIndexBuffer(GeometryData.IndexBuffer, SlimDX.DXGI.Format.R16_UInt, 0);
Context.DrawIndexed(GeometryData.IndexCount, 0, 0);
}
示例7: Render
public void Render(DeviceContext deviceContext, int indexCount, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, ShaderResourceView texture)
{
worldMatrix.Transpose();
viewMatrix.Transpose();
projectionMatrix.Transpose();
// Lock the constant memory buffer so it can be written to.
DataStream mappedResource;
deviceContext.MapSubresource(ConstantMatrixBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out mappedResource);
// Copy the transposed matrices (because they are stored in column-major order on the GPU by default) into the constant buffer.
var matrixBuffer = new MatrixBuffer
{
world = worldMatrix,
view = viewMatrix,
projection = projectionMatrix
};
mappedResource.Write(matrixBuffer);
// Unlock the constant buffer.
deviceContext.UnmapSubresource(ConstantMatrixBuffer, 0);
// Set the position of the constant buffer in the vertex shader.
const int bufferNumber = 0;
// Finally set the constant buffer in the vertex shader with the updated values.
deviceContext.VertexShader.SetConstantBuffer(bufferNumber, ConstantMatrixBuffer);
// Set shader resource in the pixel shader.
deviceContext.PixelShader.SetShaderResource(0, texture);
// Set the vertex input layout.
deviceContext.InputAssembler.InputLayout = Layout;
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext.VertexShader.Set(VertexShader);
deviceContext.PixelShader.Set(PixelShader);
// Set the sampler state in the pixel shader.
deviceContext.PixelShader.SetSampler(0, SamplerState);
// Render the triangle.
deviceContext.DrawIndexed(indexCount, 0, 0);
}
示例8: Render
public void Render(DeviceContext deviceContext, int indexCount, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix,
ShaderResourceView bumpMap, ShaderResourceView borderTexture, Vector2 translation, Light light)
{
UpdateMatrixBuffer(deviceContext, ConstantMatrixBuffer, worldMatrix, viewMatrix, projectionMatrix);
//Copy translation buffer to GPU
DataStream mappedResource;
deviceContext.MapSubresource(ConstantTranslationBuffer, MapMode.WriteDiscard, MapFlags.None, out mappedResource);
mappedResource.Write(new TranslationBuffer { translation = translation });
deviceContext.UnmapSubresource(ConstantTranslationBuffer, 0);
deviceContext.MapSubresource(ConstantLightBuffer, MapMode.WriteDiscard, MapFlags.None, out mappedResource);
mappedResource.Write(new LightBuffer(light));
deviceContext.UnmapSubresource(ConstantLightBuffer, 0);
deviceContext.InputAssembler.InputLayout = Layout;
deviceContext.VertexShader.Set(VertexShader);
deviceContext.VertexShader.SetConstantBuffer(0, ConstantMatrixBuffer);
deviceContext.PixelShader.Set(PixelShader);
deviceContext.PixelShader.SetConstantBuffer(1, ConstantTranslationBuffer);
deviceContext.PixelShader.SetConstantBuffer(2, ConstantLightBuffer);
deviceContext.PixelShader.SetSampler(0, SamplerStateWrap);
deviceContext.PixelShader.SetSampler(1, SamplerStateBorder);
deviceContext.PixelShader.SetShaderResource(0, bumpMap);
deviceContext.PixelShader.SetShaderResource(1, borderTexture);
deviceContext.DrawIndexed(indexCount, 0, 0);
}
示例9: Draw
public void Draw(DeviceContext dc, Vector3 camPos ) {
if (IB.Count == 0) {
BuildIndices(dc.Device);
}
var tessLevel = TessFactor(camPos);
dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_vb, TerrainCP.Stride, 0));
dc.InputAssembler.SetIndexBuffer(IB[tessLevel], Format.R16_UInt, 0);
dc.DrawIndexed(IndexCount[tessLevel], 0, 0);
}
示例10: Render
public void Render(DeviceContext deviceContext, int indexCount, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, ShaderResourceView terrain, ShaderResourceView water)
{
UpdateMatrixBuffer(deviceContext, ConstantMatrixBuffer, worldMatrix, viewMatrix, projectionMatrix);
deviceContext.VertexShader.SetConstantBuffer(0, ConstantMatrixBuffer);
deviceContext.VertexShader.SetShaderResource(0, terrain);
deviceContext.VertexShader.SetShaderResource(1, water);
deviceContext.VertexShader.SetSampler(1,VertexSamplerState);
deviceContext.PixelShader.SetShaderResource(0, terrain);
deviceContext.PixelShader.SetShaderResource(1, water);
deviceContext.InputAssembler.InputLayout = Layout;
deviceContext.VertexShader.Set(VertexShader);
deviceContext.PixelShader.Set(PixelShader);
deviceContext.PixelShader.SetSampler(0, SamplerState);
deviceContext.DrawIndexed(indexCount, 0, 0);
}
示例11: Render
public void Render(DeviceContext deviceContext, int indexCount, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, ShaderResourceView borderTexture, ShaderResourceView provinceColorTexture)
{
UpdateMatrixBuffer(deviceContext, ConstantMatrixBuffer, worldMatrix, viewMatrix, projectionMatrix);
deviceContext.InputAssembler.InputLayout = Layout;
deviceContext.VertexShader.Set(VertexShader);
deviceContext.VertexShader.SetConstantBuffer(0, ConstantMatrixBuffer);
deviceContext.PixelShader.Set(PixelShader);
deviceContext.PixelShader.SetSampler(0, SamplerStateBorder);
deviceContext.PixelShader.SetSampler(1, SamplerStateColor);
deviceContext.PixelShader.SetShaderResource(0, borderTexture);
deviceContext.PixelShader.SetShaderResource(1, provinceColorTexture);
deviceContext.DrawIndexed(indexCount, 0, 0);
}
示例12: DrawToShadowMap
public void DrawToShadowMap(DeviceContext dc, ShadowMap sMap, Matrix viewProj)
{
sMap.BindDsvAndSetNullRenderTarget(dc);
dc.InputAssembler.PrimitiveTopology = PrimitiveTopology.PatchListWith4ControlPoints;
dc.InputAssembler.InputLayout = InputLayouts.TerrainCP;
var stride = TerrainCP.Stride;
const int offset = 0;
dc.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_quadPatchVB, stride, offset));
dc.InputAssembler.SetIndexBuffer(_quadPatchIB, Format.R16_UInt, 0);
var frustum = Frustum.FromViewProj(viewProj);
var planes = frustum.Planes;
Effects.TerrainFX.SetViewProj(viewProj);
Effects.TerrainFX.SetEyePosW(new Vector3(viewProj.M41, viewProj.M42, viewProj.M43));
Effects.TerrainFX.SetMinDist(MinDist);
Effects.TerrainFX.SetMaxDist(MaxDist);
Effects.TerrainFX.SetMinTess(MinTess);
Effects.TerrainFX.SetMaxTess(MaxTess);
Effects.TerrainFX.SetWorldCellSpace(Info.CellSpacing);
Effects.TerrainFX.SetWorldFrustumPlanes(planes);
Effects.TerrainFX.SetHeightMap(_heightMapSRV);
var tech = Effects.TerrainFX.TessBuildShadowMapTech;
for (int p = 0; p < tech.Description.PassCount; p++) {
var pass = tech.GetPassByIndex(p);
pass.Apply(dc);
dc.DrawIndexed(_numPatchQuadFaces * 4, 0, 0);
}
dc.HullShader.Set(null);
dc.DomainShader.Set(null);
}
示例13: Render
public void Render(DeviceContext deviceContext, int indexCount, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix, Light light, ShaderResourceView[] textures, Vector4 clippingPlane)
{
worldMatrix.Transpose();
viewMatrix.Transpose();
projectionMatrix.Transpose();
// Lock the constant memory buffer so it can be written to.
DataStream mappedResource;
deviceContext.MapSubresource(ConstantMatrixBuffer, MapMode.WriteDiscard, MapFlags.None, out mappedResource);
// Copy the transposed matrices (because they are stored in column-major order on the GPU by default) into the constant buffer.
var matrixBuffer = new MatrixBuffer
{
world = worldMatrix,
view = viewMatrix,
projection = projectionMatrix
};
mappedResource.Write(matrixBuffer);
// Unlock the constant buffer.
deviceContext.UnmapSubresource(ConstantMatrixBuffer, 0);
deviceContext.MapSubresource(ConstantLightBuffer, MapMode.WriteDiscard, MapFlags.None, out mappedResource);
mappedResource.Write(
new LightBuffer
{
ambiantColor = light.AmbiantColor,
diffuseColor = light.Color,
direction = light.Direction
});
deviceContext.UnmapSubresource(ConstantLightBuffer, 0);
deviceContext.MapSubresource(ConstantClippingPlaneBuffer, MapMode.WriteDiscard, MapFlags.None, out mappedResource);
mappedResource.Write( new ClippingPlaneBuffer {plane = clippingPlane});
deviceContext.UnmapSubresource(ConstantClippingPlaneBuffer, 0);
// Finally set the constant buffers in the vertex shader with the updated values.
deviceContext.VertexShader.SetConstantBuffer(0, ConstantMatrixBuffer);
deviceContext.VertexShader.SetConstantBuffer(1, ConstantClippingPlaneBuffer);
deviceContext.PixelShader.SetConstantBuffer(0, ConstantLightBuffer);
deviceContext.PixelShader.SetShaderResources(0, textures);
// Set the vertex input layout.
deviceContext.InputAssembler.InputLayout = Layout;
// Set the vertex and pixel shaders that will be used to render this triangle.
deviceContext.VertexShader.Set(VertexShader);
deviceContext.PixelShader.Set(PixelShader);
deviceContext.PixelShader.SetSampler(0, SamplerState);
// Render the triangles.
deviceContext.DrawIndexed(indexCount, 0, 0);
}
示例14: DrawHierarchy
private void DrawHierarchy(List<ObjectNode> nodes, int materialIndex, DeviceContext devContext, int depth)
{
if (depth > 1212)
{
return;
}
foreach (var node in nodes)
{
if (node.DrawGroup != null && node.Enabled)
{
foreach (var group in node.DrawGroup)
{
if (group.materialIndex == materialIndex)
{
devContext.DrawIndexed(group.indexCount, group.startIndex, 0);
}
}
}
DrawHierarchy(node.Children, materialIndex, devContext, depth + 1);
}
}
示例15: DrawAllPasses
public static void DrawAllPasses(this EffectTechnique tech, DeviceContext context, int indexCount) {
for (var i = 0; i < tech.Description.PassCount; i++) {
tech.GetPassByIndex(i).Apply(context);
context.DrawIndexed(indexCount, 0, 0);
}
}