bgiSetActiveCanvas

Directs subsequent 2D drawing to a canvas, or pass -1 for the main window.

BGI GUI

Parameters & Returns

Parameters

canvasID Int

Returns

Void

Quick Summary

Directs subsequent 2D drawing to a canvas, or pass -1 for the main window.

Technical Exegesis...

Makes canvasID the active render target so the following b2dCls and b2d* draw calls render into that canvas instead of the main window. Pass -1 to switch back to the main window. Internally it waits for the GPU when switching between canvases (avoids buffer races) and updates the 2D overlay to the canvas dimensions so draw coordinates map correctly. The render target is bound on the next b2dCls; bgiFlipCanvas presents the canvas. Use bgiGetActiveCanvas to query the current target.

Example

Example.bam
bgiSetActiveCanvas(canvas)
b2dCls()
; ... b2d* draw calls ...
bgiFlipCanvas(canvas)
bgiSetActiveCanvas(-1)