示例#1
0
    private static void InitBackbuffer()
    {
        using ComPtr <ID3D11Resource> backbufferResource = default;
        fixed(Guid *resourcePointer = &D3D11Resource)
        {
            CheckAndThrow(_swapChain.Get()->GetBuffer(0, resourcePointer, (void **)backbufferResource.GetAddressOf()), nameof(IDXGISwapChain.GetBuffer));
        }

        ID3D11RenderTargetView *backbuffer;

        CheckAndThrow(_device.Get()->CreateRenderTargetView(backbufferResource.Get(), null, &backbuffer), nameof(ID3D11Device.CreateRenderTargetView));

        _backbufferHandle = TextureManager.CreateManual(new Texture
        {
            Format    = TextureFormats.RGBA32F,
            Width     = SwapChain.Width,
            Height    = SwapChain.Height,
            BindFlags = D3D11_BIND_FLAG.D3D11_BIND_RENDER_TARGET,
            D3DTarget = backbuffer,
            Usage     = D3D11_USAGE.D3D11_USAGE_IMMUTABLE
        });
    }