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); }
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); }
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); }
public unsafe void Draw(IDeviceContext context, IRealTime realTime) { context.ShadersForDrawing = shaders; float totalRealTime = realTime.TotalRealTime; context.SetSubresourceData(timeUbuffer, 0, new SubresourceData(new IntPtr(&totalRealTime))); context.VertexStage.UniformBuffers[0] = timeUbuffer; context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; context.InputAssembler.VertexLayout = vertexLayout; context.InputAssembler.VertexSources[0] = new VertexSource(vertexBuffer, 0, Vertex.SizeInBytes); context.InputAssembler.IndexSource = new IndexSource(indexBuffer, 0, IndexFormat.SixteenBit); context.Rasterizer.State = rasterizerState; context.OutputMerger.DepthStencilState = depthStencilState; context.OutputMerger.BlendState = blendState; context.DrawIndexed(starCount * 6, 0, 0); }
/// <summary>Render the mesh</summary> public void draw(IDeviceContext context) { context.SetVertexBuffer(0, vertexBuffer, 0); context.SetIndexBuffer(indexBuffer, 0); context.DrawIndexed(ref drawCall); }