Пример #1
0
        void renderScene(IDeviceContext ic, ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            ic.SetRenderTarget(swapChainRgb, swapChainDepthStencil, ResourceStateTransitionMode.Transition);

            // Clear the back buffer
            ic.ClearRenderTarget(swapChainRgb, clearColor);
            ic.ClearDepthStencil(swapChainDepthStencil, ClearDepthStencilFlags.DepthFlag, 1.0f, 0);

            // Map the buffer and write current world-view-projection matrix
            Matrix4x4 transposed = worldViewProjMatrix.transposed();

            ic.writeBuffer(vsConstants, ref transposed);

            // Bind vertex and index buffers
            ic.SetVertexBuffer(0, cubeVertexBuffer, 0);
            ic.SetIndexBuffer(cubeIndexBuffer, 0);

            // Set the pipeline state
            ic.SetPipelineState(pipelineState);
            // Commit shader resources. RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode makes sure that resources are transitioned to required states.
            ic.CommitShaderResources(resourceBinding);

            DrawIndexedAttribs draw = new DrawIndexedAttribs(false)
            {
                IndexType  = GpuValueType.Uint16,
                NumIndices = 36,
                Flags      = DrawFlags.VerifyAll
            };

            ic.DrawIndexed(ref draw);
        }
Пример #2
0
 public void Render(IDeviceContext context, int instanceCount)
 {
     context.SetRasterizerConfiguration(RasterizerConfiguration.FillFront);
     context.SetVertexBuffer(0, vertexBuffer);
     context.SetIndexBuffer(0, indexBuffer);
     context.SetPrimitiveTopology(PrimitiveTopology.PatchListWith3ControlPoints);
     context.DrawIndexedInstanced(indexCount, instanceCount, 0, 0, 0);
 }
Пример #3
0
        public override void Render(IDeviceContext context)
        {
            context.SetVertexBuffer(_vertexBuffer);
            context.SetIndexBuffer(_indexBuffer);
            context.SetVertexShader(_vertexShader);
            context.SetPixelShader(_pixelShader);
            context.SetInputLayout(_inputLayout);
            context.SetPixelShaderSampler(_sampler);


            context.DrawIndexed(6, 0, 0);
        }
Пример #4
0
        public void Render(IDeviceContext context, ITexture2D meshRenderTexture)
        {
            context.SetRenderTarget(_backBuffer, _depthStencil);
            context.ClearRenderTarget(_backBuffer, Color.Red);
            context.ClearDepthStencil(_depthStencil);

            context.SetInputLayout(_inputLayout);

            context.SetVertexBuffer(_vertexBuffer);
            context.SetIndexBuffer(_indexBuffer);

            context.SetPixelShader(_pixelShader);
            context.SetVertexShader(_vertexShader);


            context.SetPixelShaderResource(meshRenderTexture);

            context.DrawIndexed(6, 0, 0);
        }
Пример #5
0
 /// <summary>Render the mesh</summary>
 public void draw(IDeviceContext context)
 {
     context.SetVertexBuffer(0, vertexBuffer, 0);
     context.SetIndexBuffer(indexBuffer, 0);
     context.DrawIndexed(ref drawCall);
 }