CreateBuffer

Category: Images and Rendering

Back to System Functions


Signature

CreateBuffer(width As Integer, height As Integer) As Integer

Returns

An integer buffer handle, or 0 if the buffer could not be created.

Description

Creates an off-screen buffer that can be used as a temporary drawing surface. Buffers are useful when you want to render several shapes, images, or text items first and then draw the combined result later.

The width and height are measured in pixels. If either value is zero or negative, no buffer is created and the result is 0.

Use SetBufferTarget to begin drawing into the buffer, ClearBufferTarget to return to the main screen, and FreeBuffer when you are finished with it.

Example

Graphics 640, 480 Dim sceneLayer As Integer sceneLayer = CreateBuffer(320, 180) If sceneLayer <> 0 Then SetBufferTarget sceneLayer Cls SetDrawColor 255, 255, 255, 255 DrawFilledRect 8, 8, 64, 64 ClearBufferTarget End If