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

ID2D1DeviceContext SetTarget does not accept null #58

Closed Telanor closed 2 months ago

Telanor commented 3 months ago

The extension method throws when attempting to pass null as the target, which is necessary to resize the swapchain. I got around the issue by calling .Object.SetTarget directly but the check should probably be removed.

public static void SetTarget(this ID2D1DeviceContext context, ID2D1Image target)
{
    if (context == null)
    {
        throw new ArgumentNullException("context");
    }

    if (target == null)
    {
        throw new ArgumentNullException("context");
    }

    context.SetTarget(target);
}
smourier commented 3 months ago

Absolutely, thanks for reporting this, it's fixed in the source now https://github.com/smourier/DirectN/commit/1823415f17df5642978384e4977ef4710c2b27ae

Telanor commented 2 months ago

Thanks!