PokéRogue
    Preparing search index...

    The primary batch rendering node in Phaser's WebGL pipeline. It draws textured quads (used by Image, Sprite, BitmapText, TileSprite, and other Game Objects) in large batches for performance. Supports multi-texturing, normal-map-based lighting, and smooth pixel art rendering. Game Objects are accumulated into a vertex buffer and flushed to the GPU in a single draw call whenever possible.

    Hierarchy (View Summary)

    Index
    batchEntries: WebGLBatchEntry[]

    The entries in the batch. Each entry represents a "sub-batch" of quads which use the same pool of textures. This allows the renderer to continue to buffer quads into the same batch without needing to upload the vertex buffer. When the batch flushes, there will be one vertex buffer upload, and one draw call per batch entry.

    bytesPerIndexPerInstance: number

    The number of bytes per index per instance. This is used to advance the index buffer, and accounts for the size of a Uint16Array element.

    bytesPerInstance: number

    The number of bytes per instance, used to determine how much of the vertex buffer to upload.

    currentBatchEntry: WebGLBatchEntry

    The current batch entry being filled with textures.

    defaultConfig: BatchHandlerConfig

    The default configuration object for this handler. This is merged with the config object passed in the constructor.

    floatsPerInstance: number

    The number of floats per instance, used to determine how much of the vertex buffer to update.

    indexBuffer: WebGLBufferWrapper

    The index buffer defining vertex order.

    indicesPerInstance: number

    The number of indices per instance. This is usually 6 for a quad. Each index corresponds to a vertex in the vertex buffer.

    instanceCount: number

    The number of instances currently in the batch.

    instancesPerBatch: number

    The number of instances per batch, used to determine the size of the vertex buffer, and the number of instances to render.

    This is usually limited by the maximum number of vertices that can be distinguished with a 16-bit UNSIGNED_INT index buffer, which is 65536. This is set in the game render config as batchSize.

    The manager that owns this RenderNode.

    maxTexturesPerBatch: number

    The maximum number of textures per batch entry. This is usually set to the maximum number of texture units available, but it might be smaller for some uses.

    name: string

    The name of the RenderNode.

    The render options currently being built.

    programManager: ProgramManager

    The program manager used to create and manage shader programs. This contains shader variants.

    The current render options to which the batch is built. These help define the shader.

    topology: number

    The topology to use for the batch handler. This is the GL topology to use for the draw call.

    vertexBufferLayout: WebGLVertexBufferLayoutWrapper

    The layout, data, and vertex buffer used to store the vertex data.

    The default layout is for a quad with position, texture coordinate, texture ID, tint effect, and tint color on each vertex.

    verticesPerInstance: number

    The number of vertices per instance.

    This is usually 4 for a quad.

    Each vertex corresponds to an index in the element buffer.

    • Add a quad to the batch.

      For compatibility with TRIANGLE_STRIP rendering, the vertices are written into the buffer in the order:

      • Bottom-left
      • Top-left
      • Bottom-right
      • Top-right

      Parameters

      • currentContext: DrawingContext

        The current drawing context.

      • glTexture: WebGLTextureWrapper

        The texture to render.

      • x0: number

        The x coordinate of the top-left corner.

      • y0: number

        The y coordinate of the top-left corner.

      • x1: number

        The x coordinate of the bottom-left corner.

      • y1: number

        The y coordinate of the bottom-left corner.

      • x2: number

        The x coordinate of the top-right corner.

      • y2: number

        The y coordinate of the top-right corner.

      • x3: number

        The x coordinate of the bottom-right corner.

      • y3: number

        The y coordinate of the bottom-right corner.

      • texX: number

        The left u coordinate (0-1).

      • texY: number

        The top v coordinate (0-1).

      • texWidth: number

        The width of the texture (0-1).

      • texHeight: number

        The height of the texture (0-1).

      • tintMode: number

        The tint mode to use.

      • tintTL: number

        The top-left tint color.

      • tintBL: number

        The bottom-left tint color.

      • tintTR: number

        The top-right tint color.

      • tintBR: number

        The bottom-right tint color.

      • renderOptions: BatchHandlerQuadRenderOptions

        Optional render features.

      • Optionaltint2TL: number

        The secondary tint color for the top-left corner.

      • Optionaltint2BL: number

        The secondary tint color for the bottom-left corner.

      • Optionaltint2TR: number

        The secondary tint color for the top-right corner.

      • Optionaltint2BR: number

        The secondary tint color for the bottom-right corner.

      • ...args: any[]

        Additional arguments for subclasses.

      Returns void

    • Process textures for batching. This method is called automatically by the batch method. It returns a piece of data used for various texture tasks, depending on the render options.

      The texture datum may be used for texture ID or normal map rotation.

      Parameters

      • glTexture: WebGLTextureWrapper

        The texture to render.

      • renderOptions: object

        The current render options.

      Returns number

      The texture datum.

    • Add a quad to the batch, using explicit UV coordinates. This is intended for compatibility with mesh rendering.

      For compatibility with TRIANGLE_STRIP rendering, the vertices are written into the buffer in the order:

      • Bottom-left
      • Top-left
      • Bottom-right
      • Top-right

      Parameters

      • currentContext: DrawingContext

        The current drawing context.

      • glTexture: WebGLTextureWrapper

        The texture to render.

      • x0: number

        The x coordinate of the top-left corner.

      • y0: number

        The y coordinate of the top-left corner.

      • x1: number

        The x coordinate of the bottom-left corner.

      • y1: number

        The y coordinate of the bottom-left corner.

      • x2: number

        The x coordinate of the top-right corner.

      • y2: number

        The y coordinate of the top-right corner.

      • x3: number

        The x coordinate of the bottom-right corner.

      • y3: number

        The y coordinate of the bottom-right corner.

      • u0: number

        The u coordinate of the top-left corner.

      • v0: number

        The v coordinate of the top-left corner.

      • u1: number

        The u coordinate of the bottom-left corner.

      • v1: number

        The v coordinate of the bottom-left corner.

      • u2: number

        The u coordinate of the top-right corner.

      • v2: number

        The v coordinate of the top-right corner.

      • u3: number

        The u coordinate of the bottom-right corner.

      • v3: number

        The v coordinate of the bottom-right corner.

      • tintMode: number

        The tint mode to use.

      • tintTL: number

        The tint color for the top-left corner.

      • tintBL: number

        The tint color for the bottom-left corner.

      • tintTR: number

        The tint color for the top-right corner.

      • tintBR: number

        The tint color for the bottom-right corner.

      • renderOptions: BatchHandlerQuadRenderOptions

        Optional render features.

      • Optionaltint2TL: number

        The secondary tint color for the top-left corner.

      • Optionaltint2BL: number

        The secondary tint color for the bottom-left corner.

      • Optionaltint2TR: number

        The secondary tint color for the top-right corner.

      • Optionaltint2BR: number

        The secondary tint color for the bottom-right corner.

      • ...args: any[]

        Additional arguments for subclasses.

      Returns void

    • Finalize the texture count for the current sub-batch. This is called automatically when the render is run. It requests a shader program with the necessary number of textures, if that is less than the maximum allowed. This reduces the number of textures the GPU must handle, which can improve performance.

      Parameters

      • count: number

        The total number of textures in the batch.

      Returns void

    • By default this is an empty method hook that you can override and use in your own custom render nodes.

      This method is called at the start of the run method. Don't forget to call it in your custom method.

      Parameters

      Returns void

    • By default this is an empty method hook that you can override and use in your own custom render nodes.

      This method is called at the end of the run method. Don't forget to call it in your custom method.

      Parameters

      Returns void

    • Push the current batch entry to the batch entry list, and create a new batch entry for future use.

      Returns void

    • Set new dimensions for the renderer. This should be overridden by subclasses.

      This is called automatically when the renderer is resized.

      Parameters

      • width: number

        The new width of the renderer.

      • height: number

        The new height of the renderer.

      Returns void

    • Draw then empty the current batch.

      This method is called automatically, by either this node or the manager, when the batch is full, or when something else needs to be rendered.

      Parameters

      Returns void

    • Enables or disables debug reporting for this node.

      When enabled, the run method is replaced with a wrapper that pushes the node's name onto the manager's debug stack before execution and pops it afterwards, allowing the renderer to track which nodes are active. The original run implementation is preserved in _run.

      When disabled, the original run method is restored and _run is cleared.

      Parameters

      • debug: boolean

        Whether to report debug information.

      Returns void

    • Set the texture resolution uniforms for the current shader program. Specifically, this sets the uMainResolution uniform with the pixel dimensions of each bound texture. This information is required by shader features such as smooth pixel art rendering.

      This method is called automatically when the batch is run and the texRes render option is enabled.

      Parameters

      Returns void

    • Update the uniforms for the current shader program.

      This method is called automatically when the batch is run.

      Parameters

      Returns void

    • Compare the incoming render options against the currently active options and stage any differences into nextRenderOptions. Sets _renderOptionsChanged to true if any option has changed, signalling that the current batch should be flushed and the shader rebuilt via updateShaderConfig before the next draw.

      Parameters

      Returns void

    • Update the shader configuration based on render options. This is called automatically when the render options change.

      Returns void

    • Update the maximum number of textures per batch. This rebuilds the shader program with the new texture count. The minimum number of textures is 1, and the maximum is the number of texture units defined in the renderer. Rebuilding the shader may be expensive, so use this sparingly.

      If this runs during a batch, and the new count is less than the number of textures in the current batch entry, the batch will be flushed before the shader program is rebuilt, so none of the textures are skipped.

      This is usually called automatically by a listener for the Phaser.Renderer.Events.SET_PARALLEL_TEXTURE_UNITS event, triggered by the RenderNodeManager.

      Parameters

      • Optionalcount: number

        The new maximum number of textures per batch. If undefined, the maximum number of texture units is used.

      Returns void