phaser - v4.0.0-rc.4
    Preparing search index...

    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.

    Index

    Constructors

    • Parameters

      • renderer: WebGLRenderer

        The WebGLRenderer instance that owns this wrapper.

      • dataBuffer: ArrayBuffer

        An ArrayBuffer of data to store. The buffer will be permanently associated with this data.

      • bufferType: number

        The type of the buffer being created.

      • bufferUsage: number

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

      Returns WebGLBufferWrapper

    Properties

    bufferType: number

    The type of the buffer.

    bufferUsage: number

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

    dataBuffer: ArrayBuffer

    The data associated with the buffer.

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

    renderer: WebGLRenderer

    The WebGLRenderer instance that owns this wrapper.

    viewF32: Float32Array<ArrayBufferLike>

    A Float32Array view of the dataBuffer.

    This will be null if the byte length of the dataBuffer is not divisible by Float32Array.BYTES_PER_ELEMENT (4). Such a buffer is only suited for use with 16-bit indices.

    viewU16: Uint16Array<ArrayBufferLike>

    A Uint16Array view of the dataBuffer.

    This will be null if the byte length of the dataBuffer is not divisible by Uint16Array.BYTES_PER_ELEMENT (2). Such a buffer is only suited for use with byte data.

    viewU32: Uint32Array<ArrayBufferLike>

    A Uint32Array view of the dataBuffer.

    This will be null if the byte length of the dataBuffer is not divisible by Uint32Array.BYTES_PER_ELEMENT (4). Such a buffer is only suited for use with 16-bit indices.

    viewU8: Uint8Array

    A Uint8Array view of the dataBuffer.

    webGLBuffer: WebGLBuffer

    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.

    Methods

    • Binds this WebGLBufferWrapper to the current WebGLRenderingContext. It uses the bufferType of this wrapper to determine which binding point to use.

      Parameters

      • Optionalunbind: boolean

        Whether to unbind the buffer instead. Default false.

      Returns void

    • 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.

      Returns void

    • Resizes the dataBuffer of this WebGLBufferWrapper. This will recreate dataBuffer and the views into it. All data will be lost. All views into dataBuffer will be destroyed and recreated.

      Parameters

      • bytes: number

        The new size of the buffer in bytes.

      Returns void

    • Updates the data in this WebGLBufferWrapper. The dataBuffer must contain the new data to be uploaded to the GPU. Data will preserve its range from dataBuffer to the WebGLBuffer.

      Parameters

      • Optionalbytes: number

        The number of bytes to update in the buffer. If not specified, the entire buffer will be updated.

      • Optionaloffset: number

        The offset into the buffer to start updating data at. Default 0.

      Returns void