CanvasBuffer ( canvas )
Parameters
| canvas - canvas gadget to get the drawing buffer of |
Description
|
Returns the drawing buffer of a canvas, ready for SetBuffer and the 2D commands. Requires Extended language mode. Every canvas owns a buffer you can point the 2D drawing commands at: SetBuffer CanvasBuffer(canvas), draw with Cls, Rect, Text and friends, then present the result with FlipCanvas. The buffer is sized in physical pixels, matching CanvasPixelWidth and CanvasPixelHeight. For a plain 2D canvas this is an independent, resizable buffer - you can run several 2D canvases at once, and when the canvas is resized the overlapping pixels are preserved without the buffer handle changing. For a canvas attached to the renderer with Graphics3DCanvas, CanvasBuffer instead returns that canvas's own 2D overlay. Drawing to it affects only the addressed canvas, and FlipCanvas composes the overlay over the canvas's most recent 3D frame - so replacing or clearing overlay content never leaves stale pixels behind. That is how each viewport of a multi-view editor gets its own labels and gizmo text. Gotcha: the raw buffer handle becomes invalid after a graphics-mode change. The call is cheap, so fetch it fresh each frame rather than caching it, as the samples do. See it working in the 2D canvas sample, and with per-view overlays in the two-view and four-view editor samples and the two-window, two-world sample. See also: CreateCanvas, FlipCanvas, Graphics3DCanvas, CanvasPixelWidth, SetBuffer, RenderWorldToCanvas. |
Index