Creates an embedded DirectX12 3D rendering canvas within a BGI window.
Takes x (Int), y (Int), width (Int), height (Int), and parent (Int).
Returns canvas ID, or 0 if initialization failed.
BGI GUI
Parameters & Returns
Parameters
xInt
yInt
widthInt
heightInt
parentInt
Returns
Int
Quick Summary
Creates an embedded DirectX12 3D rendering canvas within a BGI window.
Takes x (Int), y (Int), width (Int), height (Int), and parent (Int).
Returns canvas ID, or 0 if initialization failed.
Technical Exegesis...
Creates an embedded DirectX12 3D rendering canvas within a BGI window. Checks g_3D_pDevice and g_commandListManager initialized (requires b3dGraphics3D() first). Gets graphics command queue from command list manager. Searches gizmoMap for parent BGI window via bgiGetGizmoHWND. Registers "DX12CanvasClass3D" window class (once) with CanvasWindowProc. Creates child window with WS_CHILD | WS_VISIBLE at (x, y, width, height) position.
Creates an embedded DirectX12 3D rendering canvas within a BGI window. Checks g_3D_pDevice and g_commandListManager initialized (requires b3dGraphics3D() first). Gets graphics command queue from command list manager. Searches gizmoMap for parent BGI window via bgiGetGizmoHWND. Registers "DX12CanvasClass3D" window class (once) with CanvasWindowProc. Creates child window with WS_CHILD | WS_VISIBLE at (x, y, width, height) position. Creates DXGI swap chain with DXGI_FORMAT_R8G8B8A8_UNORM, FRAME_BUFFER_COUNT buffers, DXGI_SWAP_EFFECT_FLIP_DISCARD. Enables frame latency waitable object for frame pacing. If g_3D_isSynced is false, adds DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING for unlocked FPS. Sets maximum frame latency to FRAME_BUFFER_COUNT. Creates RTV descriptor heap with FRAME_BUFFER_COUNT descriptors using g_3D_pDevice. Creates render target views for all swap chain buffers. Creates depth buffer (DXGI_FORMAT_D32_FLOAT) at canvas dimensions. Creates DSV descriptor heap and depth stencil view. Increments gizmoIDCount for unique canvas ID. Creates DX12Canvas structure in g_canvasMap with: id, hWnd, parentHWND, parentID, swapChain, rtvHeap, renderTargets, frameIndex, depthStencilBuffer, dsvHeap, dsvHandle, frameLatencyWaitableObject, supports3D=true, isFirstRender=true, x, y, width, height, isActive=false, FPS tracking fields. If canvas larger than g_3D_resolutionWidth/Height, calls DX12_ResizeMainSwapChain to ensure main swap chain buffers are large enough. Returns canvas ID, or 0 if initialization failed.
This function enables multiple 3D viewports within BGI windows for tool applications, editors, split-screen views, real-time previews. Uses g_3D_pDevice (NOT g_pDevice) - canvases must use same device as main 3D system. Each canvas has independent swap chain for separate Present() calls. Frame latency waitable object enables smooth frame pacing per canvas. Depth buffer supports 3D rendering with depth testing. CanvasWindowProc handles canvas window messages (input, resize, focus). Triple buffering (FRAME_BUFFER_COUNT) prevents tearing and enables smooth rendering. FLIP_DISCARD swap effect is modern presentation mode (required for waitable object). Tearing flag enables uncapped FPS when g_3D_isSynced=false. Canvas ID shared with gizmo ID space (uses gizmoIDCount). Use bgiSetActiveCanvas to switch render target before b3dCls3D/b3dRenderWorld. Use bgiFlipCanvas to present canvas (NOT BBR_Flip). Main swap chain resize ensures buffers accommodate largest canvas (for offscreen rendering). Canvas windows are child windows - automatically destroyed with parent. Supports3D flag distinguishes from 2D canvases (different render paths).