For the "OpenGL desktop," there is a good explanation here:
http://www.opengl.org/wiki/Buffer_Object
Basically, the usage parameter is a hint to OpenGL / WebGL about how you are going to use the buffer. OpenGL / WebGL can then optimize the buffer depending on your hint.
OpenGL ES docs writes the following, which is not quite the same as for OpenGL (remember that WebGL inherits from OpenGL ES ):
FLOW
- The contents of the data warehouse will be changed once and will be used no more than several times.
STATIC
- The contents of the data warehouse will be changed once and used many times.
DYNAMIC
- The contents of the data warehouse will be reused and reused many times.
The nature of access should be:
DRAWING
- The contents of the data warehouse are modified by the application and used as a source for GL drawing and graphic commands.
The most common use is STATIC_DRAW (for static geometry), but I recently created a small particle system in which DYNAMIC_DRAW makes more sense (particles are stored in the same buffer, where parts of the buffer are updated when particles are thrown away).
http://jsfiddle.net/mortennobel/YHMQZ/
Code snippet:
function createVertexBufferObject(){ particleBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, particleBuffer); var vertices = new Float32Array(vertexBufferSize * particleSize); gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.DYNAMIC_DRAW); bindAttributes(); } function emitParticle(x,y,velocityX, velocityY){ gl.bindBuffer(gl.ARRAY_BUFFER, particleBuffer);
Mortennobel
source share