Skip to content

Dynamically changing attribute values, does it require to create bufferinfo everytime #200

Answered by greggman
Vadi asked this question in Q&A
Discussion options

You must be logged in to vote

So first off, I want to emphasize, TWGL is not a replacement for WebGL, it's just a helper. TWGL doesn't do everything. For example TWGL has no functions for setting up blending, enabling depth test, working in stencils, etc. It's just a collection of functions to help.

If you want to update the buffer used by an attribute, there's an example here:
https://twgljs.org/examples/dynamic-buffers.html

If you have a value based attribute, first off, that's not common.

You can set it like this though

const bufferInfo = twgl.createBufferInfoFromArrays(gl, {
  position: [0.5, 0.5, 0],
  color: { value: [1, 0, 0, 1] },  // RED
});

gl.useProgram(programInfo.program);
twgl.setBuffersAndAttributes(gl…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Vadi
Comment options

Answer selected by Vadi
Comment options

You must be logged in to vote
1 reply
@greggman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #199 on July 03, 2022 18:03.