smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
311 stars 28 forks source link

Error when resizing window #31

Closed KangUnia closed 1 year ago

KangUnia commented 1 year ago

First of all I am using this library very gratefully. I am testing directx using winui3 swapchain.

However, when resizing the window, Device.CreateRenderTargetView throws an error. [COM object that has been separated from its underlying RCW cannot be used. ]

I don't understand this error, so I can't fix it.

please help ........

public void Resize(uint width, uint height) { mDeviceContext.Object.OMSetRenderTargets(0, null, null); mDeviceContext.Object.Flush(); mRenderTargetView.Dispose(); mRenderTargetView = null;

var hResult = mSwapChain.Object.ResizeBuffers(0, width, height, DXGI_FORMAT.DXGI_FORMAT_UNKNOWN, 0);

var frameBuffer = mSwapChain.GetBuffer<ID3D11Texture2D>(0);
mRenderTargetView = mDevice.CreateRenderTargetView(frameBuffer);

... }

KangUnia commented 1 year ago

use ComObject new device