PokéRogue
    Preparing search index...

    Class WebGLProgramWrapper

    Wraps a WebGL shader program, which is the GPU-side program compiled from a vertex shader and a fragment shader. Together, these shaders define how geometry is transformed and how each pixel within that geometry is colored. Every pipeline in Phaser's WebGL renderer is backed by a WebGLProgramWrapper.

    Beyond holding the compiled program, this wrapper manages the full lifecycle of the associated WebGL resources: it tracks vertex attribute locations and layout, stores uniform values, and queues uniform update requests that are applied lazily when the program is bound for drawing.

    The raw WebGLProgram object should never be used or stored directly outside of the WebGLRenderer. By routing all access through this wrapper, the renderer can transparently handle WebGL context loss and restoration — recreating the underlying program and re-applying all state — without any other system needing to be aware of it. Always use WebGLProgramWrapper instead of holding a direct WebGLProgram reference.

    Index
    • Parameters

      • renderer: WebGLRenderer

        The WebGLRenderer instance that owns this wrapper.

      • vertexSource: string

        The vertex shader source code as a string.

      • fragmentSource: string

        The fragment shader source code as a string.

      Returns WebGLProgramWrapper

    compileTimeMs: number

    The time taken to compile this program, in milliseconds.

    compiling: boolean

    Whether this program is currently being compiled. This will always be false, unless parallel shader compilation is enabled via config.render.skipUnreadyShaders.

    fragmentSource: string

    The fragment shader source code as a string.

    glAttributeBuffer: WebGLBuffer | null

    The buffer which this program is using for its attributes.

    glAttributeNames: Map<string, number>

    Map of attribute names to their indexes in glAttributes.

    glAttributes: { location: number; name: string; size: number; type: number }[]

    The attribute state of this program.

    These represent the actual state in WebGL, and are only updated when the program is used to draw.

    The WebGL state necessary to bind this program.

    This is used internally to accelerate state changes.

    glUniforms: Map<string, WebGLUniform>

    The uniform state of this program.

    These represent the actual state in WebGL, and are only updated when the program is used to draw.

    renderer: WebGLRenderer

    The WebGLRenderer instance that owns this wrapper.

    uniformRequests: Map<string, any>

    Requests to update the uniform state. Set a request by name to a new value. These are only processed when the program is used to draw.

    vertexSource: string

    The vertex shader source code as a string.

    webGLProgram: WebGLProgram | null

    The WebGLProgram 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.

    • Set this program as the active program in the WebGL context, then process all pending uniform update requests that were queued via setUniform. Each request is applied to the GPU and the queue is cleared, so only values that have actually changed are sent to WebGL.

      Returns void

    • Poll shader compilation status, and complete the program if it is ready. This is only called if skipUnreadyShaders is enabled and the KHR_parallel_shader_compile extension is available.

      Returns void

    • Creates a WebGLProgram from the given vertex and fragment shaders.

      This is called automatically by the constructor. It may also be called again if the WebGLProgram needs re-creating.

      Returns void

    • Destroys this WebGLProgramWrapper and releases all associated WebGL resources.

      If the context is not lost, this deletes the vertex shader, fragment shader, and the linked WebGLProgram from the GPU, and disables all vertex attribute arrays used by this program. The uniform map, attribute map, and any pending uniform requests are also cleared. All internal references are then nulled so this wrapper can be safely garbage-collected.

      Returns void

    • Set a uniform value for this WebGLProgram.

      This method doesn't set the WebGL value directly. Instead, it adds a request to the uniformRequests map. These requests are processed when the program is used to draw.

      Parameters

      Returns void