gameforge - v0.1.12
    Preparing search index...

    Class BatchRenderer

    Renderer dedicated to drawing and batching sprites.

    This is the default batch renderer. It buffers objects with texture-based geometries and renders them in batches. It uploads multiple textures to the GPU to reduce to the number of draw calls.

    PIXI

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _aBuffers: ViewableBuffer[]

    Pool of ViewableBuffer objects that are sorted in order of increasing size. The flush method uses the buffer with the least size above the amount it requires. These are used for passing attributes.

    The first buffer has a size of 8; each subsequent buffer has double capacity of its previous.

    PIXI.BatchRenderer#getAttributeBuffer

    _aIndex: number
    _attributeBuffer: ViewableBuffer
    _bufferedElements: IBatchableElement[]

    Buffer of objects that are yet to be rendered.

    _bufferedTextures: BaseTexture<Resource, IAutoDetectOptions>[]

    Data for texture batch builder, helps to save a bit of CPU on a pass.

    _bufferSize: number

    Number of elements that are buffered and are waiting to be flushed.

    _dcIndex: number
    _flushId: number

    A flush may occur multiple times in a single frame. On iOS devices or when BatchRenderer.canUploadSameBuffer is false, the batch renderer does not upload data to the same WebGLBuffer for performance reasons.

    This is the index into packedGeometries that points to geometry holding the most recent buffers.

    _iBuffers: Uint16Array<ArrayBufferLike>[]

    Pool of Uint16Array objects that are sorted in order of increasing size. The flush method uses the buffer with the least size above the amount it requires. These are used for passing indices.

    The first buffer has a size of 12; each subsequent buffer has double capacity of its previous.

    PIXI.BatchRenderer#getIndexBuffer

    _iIndex: number
    _indexBuffer: Uint16Array
    _indexCount: number

    Total count of all indices used by the currently buffered objects.

    _shader: Shader

    This shader is generated by this.shaderGenerator.

    It is generated specifically to handle the required number of textures being batched together.

    _tempBoundTextures: BaseTexture<Resource, IAutoDetectOptions>[]
    _vertexCount: number

    Total count of all vertices used by the currently buffered objects.

    geometryClass: typeof BatchGeometry

    The class that represents the geometry of objects that are going to be batched with this.

    PIXI.BatchGeometry
    
    maxTextures: number

    Maximum number of textures that can be uploaded to the GPU under the current context. It is initialized properly in this.contextChange.

    PIXI.BatchRenderer#contextChange

    renderer: Renderer

    The renderer this manager works for.

    shaderGenerator: BatchShaderGenerator

    This is used to generate a shader that can color each vertex based on a aTextureId attribute that points to an texture in uSampler.

    This enables the objects with different textures to be drawn in the same draw call.

    You can customize your shader by creating your custom shader generator.

    size: number

    The number of bufferable objects before a flush occurs automatically.

    PIXI.BatchRenderer.defaultBatchSize * 4
    
    state: State

    The WebGL state in which this renderer will work.

    vertexSize: number

    Size of data being buffered per vertex in the attribute buffers (in floats). By default, the batch-renderer plugin uses 6:

    aVertexPosition 2
    aTextureCoords 2
    aColor 1
    aTextureId 1
    6
    
    _drawCallPool: BatchDrawCall[]

    Pool of BatchDrawCall objects that flush used to create "batches" of the objects being rendered.

    These are never re-allocated again. Shared between all batch renderers because it can be only one "flush" working at the moment.

    _textureArrayPool: BatchTextureArray[]

    Pool of BatchDrawCall objects that flush used to create "batches" of the objects being rendered.

    These are never re-allocated again. Shared between all batch renderers because it can be only one "flush" working at the moment.

    defaultBatchSize: number

    The default sprite batch size.

    The default aims to balance desktop and mobile devices.

    Accessors

    • get MAX_TEXTURES(): number

      Returns number

      PIXI.BatchRenderer#maxTextures

      since 7.1.0

    • get canUploadSameBuffer(): boolean

      Can we upload the same buffer in a single frame?

      Returns boolean

    • set canUploadSameBuffer(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get defaultFragmentTemplate(): string

      The default fragment shader source

      Returns string

    • get defaultMaxTextures(): number

      The maximum textures that this device supports.

      Returns number

      32
      
    • set defaultMaxTextures(value: number): void

      Parameters

      • value: number

      Returns void

    • get defaultVertexSrc(): string

      The default vertex shader source

      Returns string

    Methods

    • Bind textures for current rendering

      Parameters

      Returns void

    • Populating drawcalls for rendering

      Parameters

      Returns void

    • Returns void

    • Handles the contextChange signal.

      It calculates this.maxTextures and allocating the packed-geometry object pool.

      Returns void

    • Destroys this BatchRenderer. It cannot be used again.

      Returns void

    • Returns void

    • Renders the content now and empties the current batch.

      Returns void

    • Fetches an attribute buffer from this._aBuffers that can hold atleast size floats.

      Parameters

      • size: number

        minimum capacity required

      Returns ViewableBuffer

      • buffer than can hold atleast size floats
    • Fetches an index buffer from this._iBuffers that can have at least size capacity.

      Parameters

      • size: number

        minimum required capacity

      Returns Uint16Array

      • buffer that can fit size indices.
    • Makes sure that static and dynamic flush pooled objects have correct dimensions.

      Returns void

    • Handles the prerender signal. It ensures that flushes start from the first geometry object again.

      Returns void

    • Takes the four batching parameters of element, interleaves and pushes them into the batching attribute/index buffers given.

      It uses these properties: vertexData uvs, textureId and indicies. It also uses the "tint" of the base-texture, if present.

      Parameters

      • element: IBatchableElement

        element being rendered

      • attributeBuffer: ViewableBuffer

        attribute buffer.

      • indexBuffer: Uint16Array

        index buffer

      • aIndex: number

        number of floats already in the attribute buffer

      • iIndex: number

        number of indices already in indexBuffer

      Returns void

    • Buffers the "batchable" object. It need not be rendered immediately.

      Parameters

      Returns void

    • Set the shader generator.

      Parameters

      • Optionaloptions: { fragment?: string; vertex?: string }
        • Optionalfragment?: string

          Fragment shader template

        • Optionalvertex?: string

          Vertex shader source

      Returns void

    • Starts a new sprite batch.

      Returns void

    • Stops and flushes the current batch.

      Returns void

    • Returns void