tsherif/picogl.js

Deleting VertexArray causes null binding

Closed this issue · 3 comments

why does VertexArrayy.delete() call bindVertexArray(null), can't someone have another vertexArray binded and delete then delete an old one, but this would unbind it

https://github.com/tsherif/picogl.js/blob/master/src/vertex-array.js#L167

Good catch. That should be conditional on this.appState.vertexArray. Something like this: https://github.com/tsherif/picogl.js/blob/master/src/vertex-array.js#L174-L177

Feel free to make the fix if that's clear. If not, I can do it in a few days.

curious if you think instead of

if (this.appState.vertexArray !== this)

you check both delete() and bind() as

if (gl.isVertexArray(this.vertexArray))

WebGL2 comes with the isVertexArray which verifies the if its a created VAO, I guess I have never been sure how JS actually handles comparing objects against each other with this

Those are different checks. if (this.appState.vertexArray !== this) checks if this is the currently-bound VAO. if (gl.isVertexArray(this.vertexArray)) will essentially check if this has been deleted yet (equivalent in PicoGL to if (this.vertexArray) which is used elsewhere.

To answer your question about JS comparison of objects, === checks the reference. So they're only equal if they're the exact same object.