Blitz3D+ Command Reference

Graphics3DCanvas canvas[,depth]

Parameters

canvas - canvas gadget to attach the 3D renderer to

depth (optional) - colour depth for the 3D graphics context, as in Graphics3D; 0 picks the best available (default). Only used when this call opens the context; ignored when one is already open

Description

Turns a canvas into a Direct3D 12 render target - a live 3D viewport inside your GUI.

Requires Extended language mode.

This is how an editor embeds the game view: create a window, create a canvas, call Graphics3DCanvas on it, and the full 3D command set renders into that child area instead of a separate game window. If no 3D context exists yet, the call opens one on the canvas (the depth parameter matters here, like Graphics3D's); if one is already open, the canvas is attached as an additional presentation target.

Several 3D canvases can be attached at once, and every existing one stays alive. They share one graphics device, shader cache, texture cache and mesh resources, while keeping independent swap chains, depth buffers, post-process resources, overlays and resize state. Use SetCanvasCamera and RenderWorldToCanvas to give each canvas its own view - different cameras of one world, or completely independent worlds - and FlipCanvas to present each frame.

Any 2D buffer the canvas had is replaced: CanvasBuffer now returns the canvas's overlay, which FlipCanvas composes over the 3D frame - handy for per-viewport labels. Freeing a canvas, even the last one, detaches only its target; the shared graphics and world service stays live for a later canvas until EndGraphics closes it. The focused canvas is the one that feeds direct KeyDown/MouseDown polling.

See it working in the embedded Graphics3D sample and the world editor shell sample, then multi-view in the two-view and four-view editor samples and the two-window, two-world sample.

See also: CreateCanvas, FlipCanvas, CanvasBuffer, SetCanvasCamera, RenderWorldToCanvas, Graphics3D.

Index