Blitz3D+ Command Reference

CanvasPixelWidth ( canvas )

Parameters

canvas - canvas gadget to measure

Description

Returns the width of a canvas's render surface in physical pixels.

Requires Extended language mode.

This is the real pixel width of the surface you draw on - the size CanvasBuffer, CameraViewport and CanvasMouseX all work in. It usually differs from GadgetWidth, which reports logical 96-DPI units: on a display scaled to 150%, a 400-unit-wide canvas is 600 pixels wide.

Because the canvas resizes with its window (via SetGadgetLayout), read it every frame rather than once at startup. The samples call CameraViewport camera,0,0,CanvasPixelWidth(canvas),CanvasPixelHeight(canvas) at the top of the render loop so the 3D view always fills the current canvas exactly.

See it working in the world editor shell sample.

See also: CanvasPixelHeight, CanvasMouseX, CanvasBuffer, GadgetWidth, CameraViewport.

Index