The CPU and the GPU

In preparation use one of these buffers, we tell the GPU to bind it as the current buffer. There are two current buffers: one for vertex data and the other for triangle data. We're copying vertex data, so we use the ARRAY_BUFFER binding point.

positionArray = new Float32Array(flatten(positions));

gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, positionArray, gl.STATIC_DRAW);

Once bound, we can copy the data from the array in CPU memory to the buffer in GPU memory. Note that because we're delivering raw data to a device, JavaScript values must be converted to binary floating point values.