Destroys a canvas and releases all associated DirectX12 resources.
Takes canvasID (Int).
Returns nothing.
BGI GUI
Parameters & Returns
Parameters
canvasIDInt
Returns
Void
Quick Summary
Destroys a canvas and releases all associated DirectX12 resources.
Takes canvasID (Int).
Returns nothing.
Technical Exegesis...
Destroys a canvas and releases all associated DirectX12 resources. Searches g_canvasMap for canvasID. If not found, outputs debug message and returns. If canvas is active render target (g_activeCanvasID == canvasID), resets g_activeCanvasID to -1 with warning. Releases render target resources: loops through FRAME_BUFFER_COUNT, calls renderTargets[i].Reset(). Releases rtvHeap.Reset() and swapChain.Reset(). If supports3D is true, releases depthStencilBuffer.Reset(), dsvHeap.Reset(), sets dsvHandle.
Destroys a canvas and releases all associated DirectX12 resources. Searches g_canvasMap for canvasID. If not found, outputs debug message and returns. If canvas is active render target (g_activeCanvasID == canvasID), resets g_activeCanvasID to -1 with warning. Releases render target resources: loops through FRAME_BUFFER_COUNT, calls renderTargets[i].Reset(). Releases rtvHeap.Reset() and swapChain.Reset(). If supports3D is true, releases depthStencilBuffer.Reset(), dsvHeap.Reset(), sets dsvHandle.ptr=0, sets frameLatencyWaitableObject=NULL (owned by swap chain, auto-closed on swap chain destruction). Destroys child window with DestroyWindow(hWnd). Erases canvas from g_canvasMap. No return value.
This function properly cleans up DX12 canvas resources to prevent memory leaks. Safety check prevents rendering to destroyed canvas by resetting active canvas ID. Render targets must be released before swap chain (they reference swap chain's back buffers). Frame latency waitable object is owned by swap chain - DO NOT CloseHandle manually or it causes crashes. Swap chain is released via Reset() which decrements COM reference count. DestroyWindow removes child window from parent and destroys HWND. Map erase removes canvas from tracking. If canvas was destroyed while active, next render will go to main window (-1). Common pattern: create canvases at startup, destroy at shutdown or when view closed. Destroying active canvas outputs warning to OutputDebugString. For clean shutdown, call DX12_CleanupAllCanvases() which destroys all canvases with proper GPU synchronization.