Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I use additional calls to <code>gl.bufferData(...)</code> instead of <code>gl.bufferSubData(...)</code>. I don't know if this matters or not, but I think it's the only thing I'm doing differently from your example.</p> <p>You can see my current implementation of buffer management at <a href="https://github.com/sinisterchipmunk/jax/blob/6a807a9922f084a34c5aa46f716810575075f098/src/jax/webgl/core/buffer.js#L48" rel="noreferrer">jax/buffer.js#L48</a> and an older version at <a href="https://github.com/sinisterchipmunk/webgl/blob/master/public/javascripts/engine/buffer.js#L26" rel="noreferrer">webgl/buffer.js#L26</a>. As you can see, I'm not doing anything special:</p> <pre><code>gl.bindBuffer(self.bufferType, buffer); gl.bufferData(self.bufferType, instance, self.drawType); </code></pre> <p>You can see the animation in a live demo at <a href="http://webgldemos.thoughtsincomputation.com/engine_tests/md2" rel="noreferrer">webgldemos/md2</a>.</p> <h2>However</h2> <p>If you're planning to update a lot of vertices at once then this is probably not the best method. Instead, I'd propose sending the relevant data down to the video card and performing animation directly within GLSL, so that you aren't limited by JavaScript slowness and can take advantage of hardware acceleration. In fact, I'm transitioning most of my code to work this way. Two live examples of vertex manipulation on the video card are available at <a href="http://sinisterchipmunk.github.com/blobular.html" rel="noreferrer">jax/blobular</a> and <a href="http://sinisterchipmunk.github.com/meadow.html" rel="noreferrer">jax/meadow</a>. The source code for those demos is freely available <a href="https://github.com/sinisterchipmunk/sinisterchipmunk.github.com/tree/a1d33070c7ab28ad4fac1035d1e1478b05aeca0c/src/blob" rel="noreferrer">here</a> and <a href="https://github.com/sinisterchipmunk/sinisterchipmunk.github.com/tree/a1d33070c7ab28ad4fac1035d1e1478b05aeca0c/src/meadow" rel="noreferrer">here</a>, respectively.</p> <p>I hope this was helpful to you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload