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


C# DeviceContext.Draw方法代码示例

本文整理汇总了C#中DeviceContext.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext.Draw方法的具体用法?C# DeviceContext.Draw怎么用?C# DeviceContext.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeviceContext的用法示例。


在下文中一共展示了DeviceContext.Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public static void Draw(DeviceContext context, float scale = 1f, float offset = 0f)
 {
     data.scale = scale;
     data.offset = offset;
     context.UpdateSubresource<cBuffer>(ref data, buffer, 0, 0, 0, null);
     context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
     context.InputAssembler.InputLayout = layout;
     context.InputAssembler.SetVertexBuffers(0, binding);
     context.VertexShader.Set(vertexShader);
     context.VertexShader.SetConstantBuffer(1, buffer);
     context.Draw(6, 0);
 }
开发者ID:romanchom,项目名称:Luna,代码行数:12,代码来源:ScreenQuad.cs

示例2: Draw

        internal override void Draw(DeviceContext context)
        {
            Effect effect;
            using (ShaderBytecode byteCode = ShaderBytecode.CompileFromFile("Graphics/Effects/default.fx", "bidon", "fx_5_0", ShaderFlags.OptimizationLevel3, EffectFlags.None))
            {
                effect = new Effect(context.Device, byteCode);
            }
            var technique = effect.GetTechniqueByIndex(1);
            var pass = technique.GetPassByIndex(0);
            InputLayout inputLayout = new InputLayout(context.Device, pass.Description.Signature, new[] {
                new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0),
                new InputElement("COLOR", 0, SlimDX.DXGI.Format.R8G8B8A8_UNorm, InputElement.AppendAligned, 0)
            });

            DataStream vertices = new DataStream((Vector3.SizeInBytes + 4) * 3, true, true);
            vertices.Write(new ColoredVertex(new Vector3(0.0f, 0.5f, 0.0f), new Color4(1.0f, 1.0f, 0.0f, 0.0f).ToArgb()));
            vertices.Write(new ColoredVertex(new Vector3(0.45f, -0.5f, 0.0f), new Color4(1.0f, 0.0f, 1.0f, 0.0f).ToArgb()));
            vertices.Write(new ColoredVertex(new Vector3(-0.45f, -0.5f, 0.0f), new Color4(1.0f, 0.0f, 0.0f, 1.0f).ToArgb()));
            vertices.Position = 0;
            BufferDescription bd = new BufferDescription()
            {
                Usage = ResourceUsage.Default,
                SizeInBytes = 16 * 3,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.None
            };

            var vertexBuffer = new SlimDX.Direct3D11.Buffer(context.Device, vertices, bd);

            context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, 16, 0));
            //context.InputAssembler.SetIndexBuffer(indices, Format.R16_UInt, 0);

            /* scale * rotation * translation */
            Matrix worldMatrix = Matrix.Scaling(Scale) * Matrix.RotationYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z) *  Matrix.Translation(Position);

            Matrix viewMatrix = Camera.ViewMatrix;

            Matrix projectionMatrix = Camera.ProjectionMatrix;

            effect.GetVariableByName("finalMatrix").AsMatrix().SetMatrix(worldMatrix * viewMatrix * projectionMatrix);

            context.InputAssembler.InputLayout = inputLayout;
            context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            pass.Apply(context);
            context.Draw(3, 0);
        }
开发者ID:eldernos,项目名称:SlimDXEngine,代码行数:47,代码来源:Triangle.cs

示例3: Render

 public virtual void Render(DeviceContext deviceContext, ShaderResourceView inputRV, RenderTargetView renderTargetView)
 {
     deviceContext.InputAssembler.SetVertexBuffers(0, vertexBufferBinding);
     deviceContext.InputAssembler.InputLayout = null;
     deviceContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleStrip;
     deviceContext.OutputMerger.SetTargets(renderTargetView);
     deviceContext.Rasterizer.State = rasterizerState;
     deviceContext.Rasterizer.SetViewport(viewport);
     deviceContext.VertexShader.SetShaderResource(0, null); // TODO: this should be done by the depthAndColorVS
     deviceContext.VertexShader.Set(vertexShader);
     deviceContext.GeometryShader.Set(null);
     deviceContext.PixelShader.Set(pixelShader);
     deviceContext.PixelShader.SetShaderResource(0, inputRV);
     if (constantBuffer != null)
         deviceContext.PixelShader.SetConstantBuffer(0, constantBuffer);
     deviceContext.Draw(4, 0);
     RenderTargetView nullRTV = null;
     deviceContext.OutputMerger.SetTargets(nullRTV);
     deviceContext.PixelShader.SetShaderResource(0, null);
 }
开发者ID:Dallemanden,项目名称:RoomAliveToolkit,代码行数:20,代码来源:FilterPixelShader.cs

示例4: RenderNotIndexed

 public void RenderNotIndexed(DeviceContext deviceContext, int vertexCount, 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.Draw(vertexCount,0);
 }
开发者ID:ndech,项目名称:Alpha,代码行数:9,代码来源:ColorShader.cs

示例5: RenderTileCacheEntry


//.........这里部分代码省略.........
                tileMaxExtentX = datasetExtentDataSpaceX;
            }
            if ( datasetExtentDataSpaceY > 0 && tileMaxExtentY > datasetExtentDataSpaceY )
            {
                tileProportionClipY = 1 - ( ( tileMaxExtentY - datasetExtentDataSpaceY ) / ( tileMaxExtentY - tileMinExtentY ) );
                tileMaxExtentY = datasetExtentDataSpaceY;
            }

            var p1 = new Vector3( tileMinExtentX, tileMinExtentY, 0.5f );
            var p2 = new Vector3( tileMinExtentX, tileMaxExtentY, 0.5f );
            var p3 = new Vector3( tileMaxExtentX, tileMaxExtentY, 0.5f );
            var p4 = new Vector3( tileMaxExtentX, tileMinExtentY, 0.5f );

            var t1 = new Vector3( 0f, 0f, 0f );
            var t2 = new Vector3( 0f, tileProportionClipY, 0f );
            var t3 = new Vector3( tileProportionClipX, tileProportionClipY, 0f );
            var t4 = new Vector3( tileProportionClipX, 0f, 0f );

            DataBox databox;

            databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p1 );
            databox.Data.Write( p4 );
            databox.Data.Write( p2 );
            databox.Data.Write( p3 );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            databox = deviceContext.MapSubresource( mTexCoordVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( t1 );
            databox.Data.Write( t4 );
            databox.Data.Write( t2 );
            databox.Data.Write( t3 );

            deviceContext.UnmapSubresource( mTexCoordVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );
            deviceContext.InputAssembler.SetVertexBuffers( TEXCOORD_SLOT,
                                                           new VertexBufferBinding( mTexCoordVertexBuffer,
                                                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gSourceTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "SourceMap" ) );
            if ( mTileManager.SegmentationLoaded )
            {
                //if ( tileCacheEntry.D3D11CudaTextures.Internal.ContainsKey( "IdMap" ) )
                //{
                //    mEffect.GetVariableByName( "gIdTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "IdMap" ) );
                //}
                //else
                //{
                //    System.Console.WriteLine("Warning: expected IdMap not found.");
                //}
                mEffect.GetVariableByName( "gIdTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "IdMap" ) );
                mEffect.GetVariableByName( "gIdColorMapBuffer" ).AsResource().SetResource( mTileManager.Internal.GetIdColorMap() );
                mEffect.GetVariableByName( "gLabelIdMapBuffer" ).AsResource().SetResource( mTileManager.Internal.GetLabelIdMap() );
                mEffect.GetVariableByName( "gIdConfidenceMapBuffer" ).AsResource().SetResource( mTileManager.Internal.GetIdConfidenceMap() );

                if ( tileCacheEntry.D3D11CudaTextures.Internal.ContainsKey( "OverlayMap" ) )
                {
                    mEffect.GetVariableByName( "gOverlayTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "OverlayMap" ) );
                }
            }
            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mEffect.GetVariableByName( "gSegmentationRatio" ).AsScalar().Set( mTileManager.SegmentationVisibilityRatio );
            mEffect.GetVariableByName( "gBoundaryLinesVisible" ).AsScalar().Set( mTileManager.ShowBoundaryLines );
            mEffect.GetVariableByName( "gBrushVisible" ).AsScalar().Set( mTileManager.SelectedSegmentId != 0 );
            mEffect.GetVariableByName( "gSelectedSegmentId" ).AsScalar().Set( mTileManager.SelectedSegmentId );
            mEffect.GetVariableByName( "gMouseOverSegmentId" ).AsScalar().Set( mTileManager.MouseOverSegmentId );

            mEffect.GetVariableByName( "gMouseOverX" ).AsScalar().Set( ( mTileManager.MouseOverX - tileMinExtentX ) / tileCacheEntry.ExtentDataSpace.X );
            mEffect.GetVariableByName( "gMouseOverY" ).AsScalar().Set( ( mTileManager.MouseOverY - tileMinExtentY ) / tileCacheEntry.ExtentDataSpace.Y );
            mEffect.GetVariableByName( "gMouseHighlightSize" ).AsScalar().Set( mTileManager.BrushSize );

            mPass.Apply( deviceContext );
            deviceContext.Draw( QUAD_NUM_VERTICES, 0 );

            //mDebugRenderer.RenderQuadWireframeOnly( deviceContext, p1, p2, p3, p4, new Vector3( 1, 0, 0 ), camera );
        }
开发者ID:Rhoana,项目名称:Mojo,代码行数:101,代码来源:AdjustSegmentationRenderingStrategy.cs

示例6: RenderSphereWireframeOnly

        public void RenderSphereWireframeOnly( DeviceContext deviceContext, Vector3 p, float radius, Vector3 color, Camera camera )
        {
            var databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                        0,
                                                        NUM_VERTICES *
                                                        POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                        POSITION_NUM_BYTES_PER_COMPONENT,
                                                        MapMode.WriteDiscard,
                                                        SlimDX.Direct3D11.MapFlags.None );

            var currentPoint = new Vector3();
            var furtherSouthPoint = new Vector3();
            var numVertices = 0;

            // northSouthTheta traces from north pole to south pole
            float northSouthTheta = (float)Math.PI / 2;

            for ( int i = 0; i <= NUM_LATITUDE_LINES; i++ )
            {
                float currentLatitudeRadius = (float)Math.Cos( northSouthTheta ) * radius;
                float nextLatitudeRadius = (float)Math.Cos( northSouthTheta + LATITUDE_STEP ) * radius;

                // eastWestTheta traces around each latitude line
                float eastWestTheta = 0;

                for ( int j = 0; j <= NUM_LONGITUDE_LINES; j++ )
                {
                    currentPoint.X = p.X + ( (float)Math.Cos( eastWestTheta ) * currentLatitudeRadius );
                    currentPoint.Y = p.Y + ( (float)Math.Sin( northSouthTheta ) * radius );
                    currentPoint.Z = p.Z + ( (float)Math.Sin( eastWestTheta ) * currentLatitudeRadius );

                    databox.Data.Write( currentPoint );
                    numVertices++;

                    furtherSouthPoint.X = p.X + ( (float)Math.Cos( eastWestTheta ) * nextLatitudeRadius );
                    furtherSouthPoint.Y = p.Y + ( (float)Math.Sin( northSouthTheta + LATITUDE_STEP ) * radius );
                    furtherSouthPoint.Z = p.Z + ( (float)Math.Sin( eastWestTheta ) * nextLatitudeRadius );

                    databox.Data.Write( furtherSouthPoint );
                    numVertices++;

                    eastWestTheta += LONGITUDE_STEP;
                }

                northSouthTheta += LATITUDE_STEP;
            }

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderWireframeInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mEffect.GetVariableByName( "gColor" ).AsVector().Set( color );

            mRenderWireframePass.Apply( deviceContext );
            deviceContext.Draw( numVertices, 0 );
        }
开发者ID:Rhoana,项目名称:Mojo,代码行数:63,代码来源:DebugRenderer.cs

示例7: RenderQuadTexture3DOnly

        public void RenderQuadTexture3DOnly( DeviceContext deviceContext, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 t1, Vector3 t2, Vector3 t3, Vector3 t4, ShaderResourceView texture, Camera camera )
        {
            DataBox databox;

            databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p1 );
            databox.Data.Write( p4 );
            databox.Data.Write( p2 );
            databox.Data.Write( p3 );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            databox = deviceContext.MapSubresource( mTexCoordVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( t1 );
            databox.Data.Write( t4 );
            databox.Data.Write( t2 );
            databox.Data.Write( t3 );

            deviceContext.UnmapSubresource( mTexCoordVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderTexture3DInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );
            deviceContext.InputAssembler.SetVertexBuffers( TEXCOORD_SLOT,
                                                           new VertexBufferBinding( mTexCoordVertexBuffer,
                                                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gTexture3D" ).AsResource().SetResource( texture );
            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );

            mRenderTexture3DPass.Apply( deviceContext );
            deviceContext.Draw( QUAD_NUM_VERTICES, 0 );
        }
开发者ID:Rhoana,项目名称:Mojo,代码行数:53,代码来源:DebugRenderer.cs

示例8: RenderQuadSolidOnly

        public void RenderQuadSolidOnly( DeviceContext deviceContext, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 color, Camera camera )
        {
            DataBox databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p1 );
            databox.Data.Write( p4 );
            databox.Data.Write( p2 );
            databox.Data.Write( p3 );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderSolidInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mEffect.GetVariableByName( "gColor" ).AsVector().Set( color );

            mRenderSolidPass.Apply( deviceContext );
            deviceContext.Draw( QUAD_NUM_VERTICES, 0 );
        }
开发者ID:Rhoana,项目名称:Mojo,代码行数:31,代码来源:DebugRenderer.cs

示例9: Render

        public void Render(DeviceContext deviceContext, MeshDeviceResources meshDeviceResources, PointLight pointLight, RenderTargetView renderTargetView, DepthStencilView depthStencilView, Viewport viewport)
        {
            deviceContext.InputAssembler.InputLayout = vertexInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            deviceContext.InputAssembler.SetVertexBuffers(0, meshDeviceResources.vertexBufferBinding);
            deviceContext.Rasterizer.State = rasterizerState;
            deviceContext.Rasterizer.SetViewport(viewport);
            deviceContext.VertexShader.Set(meshVS);
            deviceContext.VertexShader.SetConstantBuffer(0, vertexShaderConstantBuffer);
            deviceContext.GeometryShader.Set(null);
            deviceContext.PixelShader.SetSampler(0, colorSamplerState);
            deviceContext.PixelShader.SetConstantBuffer(0, pixelShaderConstantBuffer);
            deviceContext.OutputMerger.SetTargets(depthStencilView, renderTargetView);
            deviceContext.OutputMerger.DepthStencilState = depthStencilState;

            foreach (var subset in meshDeviceResources.mesh.subsets)
            //var subset = meshDeviceResources.mesh.subsets[meshDeviceResources.mesh.subsets.Count - 2];
            {
                if (subset.material.textureFilename != null)
                {
                    deviceContext.PixelShader.Set(meshWithTexturePS);
                    deviceContext.PixelShader.SetShaderResource(0, meshDeviceResources.textureRVs[subset]);
                }
                else
                    deviceContext.PixelShader.Set(meshPS);

                SetPixelShaderConstants(deviceContext, subset.material, pointLight);
                deviceContext.Draw(subset.length, subset.start);
            }
        }
开发者ID:rolandsmeenk,项目名称:RoomAliveToolkit,代码行数:30,代码来源:MeshShader.cs

示例10: Render

        public void Render(DeviceContext deviceContext, ShaderResourceView depthImageTextureRV, ShaderResourceView colorImageTextureRV, SharpDX.Direct3D11.Buffer vertexBuffer, RenderTargetView renderTargetView, DepthStencilView depthStencilView, Viewport viewport)
        {
            //bilateralFilter.Render(deviceContext, depthImageTextureRV, filteredRenderTargetView2);
            //bilateralFilter.Render(deviceContext, filteredDepthImageSRV2, filteredRenderTargetView);

            //bilateralFilter.Render(deviceContext, filteredDepthImageSRV, filteredRenderTargetView2);
            //bilateralFilter.Render(deviceContext, filteredDepthImageSRV2, filteredRenderTargetView);

            deviceContext.InputAssembler.InputLayout = vertexInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, VertexPosition.SizeInBytes, 0)); // bytes per vertex
            deviceContext.Rasterizer.State = rasterizerState;
            deviceContext.Rasterizer.SetViewport(viewport);
            deviceContext.VertexShader.Set(depthAndColorVS);
            deviceContext.VertexShader.SetShaderResource(0, depthImageTextureRV);
            //deviceContext.VertexShader.SetShaderResource(0, depthAndMaskRV);
            //deviceContext.VertexShader.SetShaderResource(0, filteredDepthImageSRV);
            deviceContext.VertexShader.SetConstantBuffer(0, constantBuffer);
            deviceContext.GeometryShader.Set(depthAndColorGS);
            deviceContext.PixelShader.Set(depthAndColorPS);
            deviceContext.PixelShader.SetShaderResource(0, colorImageTextureRV);
            deviceContext.PixelShader.SetSampler(0, colorSamplerState);
            deviceContext.OutputMerger.SetTargets(depthStencilView, renderTargetView);
            deviceContext.OutputMerger.DepthStencilState = depthStencilState;
            deviceContext.Draw((Kinect2Calibration.depthImageWidth - 1) * (Kinect2Calibration.depthImageHeight - 1) * 6, 0);
        }
开发者ID:virrkharia,项目名称:RoomAliveToolkit,代码行数:26,代码来源:DepthAndColorShader.cs

示例11: Render

        public void Render(DeviceContext context)
        {
            // configure the Input Assembler portion of the pipeline with the vertex data
            context.InputAssembler.InputLayout = vertexBufferLayout;
            context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
            context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, vertexSize, 0));

            // set the shaders
            context.VertexShader.Set(vertexShader);
            context.VertexShader.SetConstantBuffer(constantBuffer, 0);

            context.PixelShader.Set(pixelShader);

            context.PixelShader.SetSampler(samplerLinear, 0);
            context.PixelShader.SetShaderResource(textureView, 0);

            context.OutputMerger.BlendState = blendState;

            // Note, one can use the: SlimDX.Toolkit.ConstantBuffer<T>
            var box = context.MapSubresource(constantBuffer, MapMode.WriteDiscard, MapFlags.None);
            box.Data.Write(cb.PrepareData());
            context.UnmapSubresource(constantBuffer, 0);

            // draw the triangle
            context.Draw(vertexCount, 0);
        }
开发者ID:gitsly,项目名称:game,代码行数:26,代码来源:RenderObject.cs

示例12: Render

 /// <summary>
 /// Draws the mesh vertices.
 /// </summary>
 /// <param name="device">The device context to use.</param>
 public void Render(DeviceContext context)
 {
     context.InputAssembler.SetVertexBuffers(0, new[] { vertexBuffer });
     context.Draw(vertices.Description.SizeInBytes / vertexBuffer.Stride, 0);
 }
开发者ID:TomCrypto,项目名称:Insight,代码行数:9,代码来源:Mesh.cs

示例13: Render

        /// <summary>
        /// Draw the 3d mesh to screen
        /// </summary>
        public override void Render( DeviceContext devCont )
        {
            Device dev = Engine.g_device;

            // empty the list

            //Performance.BeginEvent(new Color4(System.Drawing.Color.Turquoise), "Set Buffers");

            /// set the layout to the engine
            devCont.InputAssembler.InputLayout = m_input_layout;

            // set the type of primitive(triangleList)
            devCont.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            // set the vertex buffer
            devCont.InputAssembler.SetVertexBuffers( 0, m_VertexBufferBinding );

            // set the index buffer
            //     dev.ImmediateContext.InputAssembler.SetIndexBuffer(m_BufferIndices, Format.R32_UInt, 0);

            /// set the position of the mesh base on the world matrix
            /// all the change pass to the shader
            m_shader.SetThePositions(m_WorldMatrix);

            //Performance.EndEvent();

            //Performance.BeginEvent(new Color4(System.Drawing.Color.Tomato), "Execute Shaders");
            /// Execute all the passes of the shader
            m_shader.Execute( devCont );
            //Performance.EndEvent();

            //Performance.BeginEvent(new Color4(System.Drawing.Color.PaleVioletRed), "Draw");
            // Render
            devCont.Draw( m_polygons.Count * 3, 0 );
            //Performance.EndEvent();
        }
开发者ID:fxbit,项目名称:FxGraphicsEngine,代码行数:39,代码来源:Mesh.cs

示例14: Render

        public void Render(DeviceContext deviceContext, ShaderResourceView depthImageTextureRV, ShaderResourceView colorImageTextureRV, SharpDX.Direct3D11.Buffer vertexBuffer, RenderTargetView renderTargetView, DepthStencilView depthStencilView, Viewport viewport)
        {
            deviceContext.InputAssembler.InputLayout = vertexInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            deviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, 16, 0)); // bytes per vertex
            deviceContext.OutputMerger.SetTargets(depthStencilView, renderTargetView);
            deviceContext.OutputMerger.DepthStencilState = depthStencilState;
            deviceContext.Rasterizer.State = rasterizerState;
            deviceContext.Rasterizer.SetViewport(viewport);
            deviceContext.VertexShader.Set(vertexShader);
            deviceContext.VertexShader.SetShaderResource(0, depthImageTextureRV);
            deviceContext.VertexShader.SetConstantBuffer(0, constantBuffer);
            deviceContext.GeometryShader.Set(geometryShader);
            deviceContext.PixelShader.Set(pixelShader);
            deviceContext.PixelShader.SetShaderResource(0, colorImageTextureRV);
            deviceContext.PixelShader.SetSampler(0, colorSamplerState);
            deviceContext.Draw((Kinect2Calibration.depthImageWidth - 1) * (Kinect2Calibration.depthImageHeight - 1) * 6, 0);

            deviceContext.VertexShader.SetShaderResource(0, null); // to avoid warnings when these are later set as render targets
            deviceContext.PixelShader.SetShaderResource(0, null);
        }
开发者ID:Dallemanden,项目名称:RoomAliveToolkit,代码行数:21,代码来源:ProjectiveTexturingShader.cs

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


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