webgl - bufferData - usage parameter differences -


while reading specification @ khronos, found:

bufferdata(ulong target, object data, ulong usage)  

'usage' parameter can be: stream_draw, static_draw or dynamic_draw

my question is, 1 should use? advantages, differences? why choose use other instead static_draw?

thanks.

for 'desktop' opengl, there explanation here:

http://www.opengl.org/wiki/buffer_object

basically, usage parameter is hint opengl/webgl on how intend use buffer. opengl/webgl can optimize buffer depending on hint.

the opengl es docs writes following, not same opengl (remember webgl inherited opengl es):

stream

  • the data store contents modified once , used @ few times.

static

  • the data store contents modified once , used many times.

dynamic

  • the data store contents modified repeatedly , used many times.

the nature of access must be:

draw

  • the data store contents modified application, , used source gl drawing , image specification commands.

the common usage static_draw (for static geometry), have created small particle system dynamic_draw makes more sense (the particles stored in single buffer, parts of buffer updated when particles emitted).

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);     // ...     gl.buffersubdata(gl.array_buffer, particleid*particlesize*sizeoffloat, data);     particleid = (particleid +1 )%vertexbuffersize; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -