Wrapper for a WebGL buffer, containing all the information that was used to create it. This can be a VertexBuffer or IndexBuffer.
A WebGLBuffer should never be exposed outside the WebGLRenderer, so the WebGLRenderer can handle context loss and other events without other systems having to be aware of it. Always use WebGLBufferWrapper instead.
new WebGLBufferWrapper(gl, initialDataOrSize, bufferType, bufferUsage)
name | type | description |
---|---|---|
gl | WebGLRenderingContext |
The WebGLRenderingContext to create the WebGLBuffer for. |
initialDataOrSize | ArrayBuffer | number |
Either an ArrayBuffer of data, or the size of the buffer to create. |
bufferType | GLenum |
The type of the buffer being created. |
bufferUsage | GLenum |
The usage of the buffer being created. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. |
The type of the buffer.
The usage of the buffer. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW.
The WebGLRenderingContext that owns this WebGLBuffer.
The initial data or size of the buffer.
Note that this will be used to recreate the buffer if the WebGL context is lost.
The WebGLBuffer being wrapped by this class.
This property could change at any time. Therefore, you should never store a reference to this value. It should only be passed directly to the WebGL API for drawing.
Creates a WebGLBuffer for this WebGLBufferWrapper.
This is called automatically by the constructor. It may also be called again if the WebGLBuffer needs re-creating.
Remove this WebGLBufferWrapper from the GL context.