public void ClearTargetColor(Texture texture, float r, float g, float b, float a) { ResourceTransition(texture, ResourceStates.RenderTarget, ResourceStates.Present); nativeCommandList.ClearRenderTargetView(texture.NativeRenderTargetView, new Vortice.Mathematics.Color4(r, g, b, a)); nativeCommandList.OMSetRenderTargets(texture.NativeRenderTargetView); }
public void Tick() { _commandAllocator.Reset(); _commandList.Reset(_commandAllocator, null); // Indicate that the back buffer will be used as a render target. _commandList.ResourceBarrierTransition(_renderTargets[_frameIndex], ResourceStates.Present, ResourceStates.RenderTarget); var rtvHandle = _rtvHeap.GetCPUDescriptorHandleForHeapStart(); rtvHandle += _frameIndex * _rtvDescriptorSize; // Record commands. Color4 clearColor = new Color4(0.0f, 0.2f, 0.4f, 1.0f); _commandList.ClearRenderTargetView(rtvHandle, clearColor); // Indicate that the back buffer will now be used to present. _commandList.ResourceBarrierTransition(_renderTargets[_frameIndex], ResourceStates.RenderTarget, ResourceStates.Present); _commandList.Close(); // Execute the command list. _d3d12CommandQueue.ExecuteCommandList(_commandList); var result = SwapChain.Present(1, PresentFlags.None); if (result.Failure && result.Code == Vortice.DXGI.ResultCode.DeviceRemoved.Code) { } WaitForPreviousFrame(); }