Vertex buffers are the data structures and memory where all the vertex data that can be rendered is stored. A vertex buffer is created when getVBOId is called, which will create (or recreate) a position in the vertex buffer array, then return the id for that buffer. This id is then used by all future functions that modify or use the vertex buffer. When this id is passed in with the draw function, WebRender read the vertex data and draws it to screen.
The WebRender pipeline uses 32-bit floats to handle all vertex attributes, this allows for the interpolation during rasterisation. Therefore, all vertex data is stored within a 32-bit float typed array which is loaded in by the user application with loadVBO. WebRender makes a copy of this data when it stores it in the vertex buffer.
The ordering of the data is defined by the shader program that you intend to use it with. WebRender only supports basic interleaved vertex data, every three vertices in a row is a single triangle and all data for each vertex is stored together. This structure can be seen in the image above. This format was chosen to reduce complexity in the vertex sampling section of the pipeline, however it does require more memory than more advanced vertex formats found in other libraries. WebRender uses counter-clockwise ordering for backface culling, therefore your vertices must be in counter-clockwise order for the triangle to face the correct way.
In order to free up memory, it is advised to clear vertex buffers once you are finished drawing them (such as when they are removed from the scene). clearVBO has been provided to do this. It will release all the data stored in the vertex buffer to be cleaned up by garbage collection and also allow the id of the buffer to be used again, potentially on the getVBOId call.
Vertex Buffers are where all your vertex data is stored for WebRender to render.
Triangles are stored as three vertices ordered sequentially in counter-clockwise order.
The order of the vertex attributes is defined by the shader you create.
Delete vertex buffers once their data no longer needs to be rendered.