From d6606d90f6c62f2ec46917ca92793deaca5da9b4 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 2 Mar 2022 09:39:23 -0800 Subject: [PATCH] AcquireSwapchainTexture nullable --- src/Graphics/CommandBuffer.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index e083f6b6..9b7c9161 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -657,13 +657,24 @@ namespace MoonWorks.Graphics /// Acquires a swapchain texture. /// This texture will be presented to the given window when the command buffer is submitted. /// - public Texture AcquireSwapchainTexture( + public Texture? AcquireSwapchainTexture( Window window ) { + var texturePtr = Refresh.Refresh_AcquireSwapchainTexture( + Device.Handle, + Handle, + window.Handle + ); + + if (texturePtr == IntPtr.Zero) + { + return null; + } + return new Texture( Device, - Refresh.Refresh_AcquireSwapchainTexture(Device.Handle, Handle, window.Handle), + texturePtr, Device.GetSwapchainFormat(window), window.Width, window.Height