CreateComputeBuffer

Family: Compute · 2 forms

What it does

CreateComputeBuffer creates Buffer on a Compute object. It takes elementCount (an integer) and elementType (a string), and answers an integer. That is the first of 2 forms.

Syntax

1
CreateComputeBuffer(elementCount integer, elementType string) → integer
2
CreateComputeBuffer(bufferID integer, elementCount integer, elementType string)

Parameters

NameTypeIn forms
elementCountintegerall
elementTypestringall
bufferIDinteger2

What each form returns

1computeBuffer = CreateComputeBuffer(10, "value")integer
2CreateComputeBuffer(1, 10, "value")nothing

Example · generated

Form 1, the command hands back the id

computeBuffer = CreateComputeBuffer(10, "value")DO  Sync()LOOP

Form 2, you choose the id yourself

CreateComputeBuffer(1, 10, "value")DO  Sync()LOOP

CreateComputeBuffer is called and its answer is printed every frame. The DO … LOOP is not decoration: a classic BASIC program ends the moment it runs out of lines, and Sync() is what draws the frame.

Related commands

14 commands in Compute