bgiCreateCanvas

Creates a 2D drawing canvas embedded in a BGI window. Returns a canvas ID (0 on failure).

BGI GUI

Parameters & Returns

Parameters

x Int
y Int
width Int
height Int
parent Int

Returns

Int

Quick Summary

Creates a 2D drawing canvas embedded in a BGI window. Returns a canvas ID (0 on failure).

Technical Exegesis...

Creates a child render surface at (x, y) of size width x height inside the BGI window `parent`. The canvas has its own swap chain on the shared graphics device. Draw into it each frame by making it the active target with bgiSetActiveCanvas, issuing 2D draw calls (b2dCls + b2d* primitives/images/text), then presenting it with bgiFlipCanvas. Requires b2dGraphics() to have been called first. The returned ID shares the gizmo ID space; canvas child windows are destroyed automatically with their parent window.

Example

Example.bam
canvas = bgiCreateCanvas(20, 20, 480, 320, window)
bgiSetActiveCanvas(canvas)
b2dCls()
; ... b2d* draw calls ...
bgiFlipCanvas(canvas)
bgiSetActiveCanvas(-1)