litegl.js icon indicating copy to clipboard operation
litegl.js copied to clipboard

Multiple contexts on the same page

Open dheera opened this issue 4 years ago • 1 comments
trafficstars

Is there a good example illustrating multiple contexts on the same page? I'm getting WebGL: INVALID_OPERATION: bindBuffer: object does not belong to this context and not quite sure where to start.

dheera avatar Jul 18 '21 06:07 dheera

Dug through the code and found the (undocumented) solution. Instead of doing e.g.

    this.gl = GL.Create( ... )
    ...
    this.yourMesh = GL.Mesh.load({vertices: this.yourPoints, colors: this.yourColors});

You need to do

    this.gl = GL.Create( ... )
    ...
    this.yourMesh = GL.Mesh.load({vertices: this.yourPoints, colors: this.yourColors}, null, null, this.gl);

dheera avatar Jul 19 '21 17:07 dheera