Phaser API Documentation

  Version: 
Filter

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.

Constructor:

new WebGLBufferWrapper(gl, initialDataOrSize, bufferType, bufferUsage)

Parameters:

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.

Members

bufferType: GLenum
Focus
Focus

Description:

The type of the buffer.

Type:
GLenum
Focus
Focus
bufferUsage: GLenum
Focus
Focus

Description:

The usage of the buffer. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW.

Type:
GLenum
Focus
Focus
gl: WebGLRenderingContext
Focus
Focus

Description:

The WebGLRenderingContext that owns this WebGLBuffer.

Type:
WebGLRenderingContext
Focus
Focus
initialDataOrSize: ArrayBuffer | number
Focus
Focus

Description:

The initial data or size of the buffer.

Note that this will be used to recreate the buffer if the WebGL context is lost.

Type:
ArrayBuffer | number
Focus
Focus
<nullable> webGLBuffer: WebGLBuffer
Focus
Focus

Description:

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.

Type:
WebGLBuffer
Default: null
Focus
Focus

Methods

createResource()
Focus
Focus

Description:

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.

Focus
Focus
destroy()
Focus
Focus

Description:

Remove this WebGLBufferWrapper from the GL context.

Focus
Focus