当前位置: 首页>>代码示例>>C#>>正文


C# DeviceContext.DrawIndexed方法代码示例

本文整理汇总了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);
 }
开发者ID:ndech,项目名称:Alpha,代码行数:9,代码来源:ColorShader.cs

示例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);
 }
开发者ID:oguna,项目名称:AssimpSharp,代码行数:12,代码来源:FbxMesh.cs

示例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);
            }
        }
开发者ID:modulexcite,项目名称:rasterizr,代码行数:17,代码来源:Model.cs

示例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);
            }
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:19,代码来源:Model.cs

示例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);
            }
        }
开发者ID:amitprakash07,项目名称:dx11,代码行数:21,代码来源:Sky.cs

示例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);
        }
开发者ID:RomanHodulak,项目名称:DeferredLightingD3D11,代码行数:12,代码来源:GeometricPrimitive.cs

示例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);
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:43,代码来源:TextureShader.cs

示例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);
        }
开发者ID:ndech,项目名称:Alpha,代码行数:29,代码来源:WorldWaterShader.cs

示例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);
        }
开发者ID:amitprakash07,项目名称:dx11,代码行数:11,代码来源:Patch.cs

示例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);
 }
开发者ID:ndech,项目名称:Alpha,代码行数:15,代码来源:SphericalTerrainShader.cs

示例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);
        }
开发者ID:ndech,项目名称:Alpha,代码行数:16,代码来源:TerrainShader.cs

示例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);
        }
开发者ID:jackinf,项目名称:dx11,代码行数:35,代码来源:Terrain.cs

示例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);
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:57,代码来源:TerrainShader.cs

示例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);
     }
 }
开发者ID:bluephoton,项目名称:wwt-windows-client,代码行数:21,代码来源:Object3d.cs

示例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);
     }
 }
开发者ID:gro-ove,项目名称:actools,代码行数:6,代码来源:SlimDxExtension.cs


注:本文中的DeviceContext.DrawIndexed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。