PokéRogue
    Preparing search index...

    The ProgramManager is a utility class used to manage instantiated shader programs and a suite of associated data, such as a VAO. It maintains a shared pool of uniforms, so if a different shader program is used, the uniforms can be applied to the new program.

    Index
    attributeBufferLayouts: WebGLAttributeBufferLayout[]

    The attribute buffer layouts to use in the program. These are used to create a VAO.

    currentConfig: object

    The configuration object currently being assembled.

    currentProgramKey: string | null

    The key of the currently active shader program.

    indexBuffer: WebGLBufferWrapper | null

    The index buffer to use in the program, if any. This is used to create a VAO.

    programs: object

    A map of shader programs and associated data suite, identified by a unique key.

    Each key corresponds to an object of the following shape:

    • program (WebGLProgramWrapper) - The compiled shader program.
    • vao (WebGLVAOWrapper) - The VAO associated with the program.
    • config (object) - The configuration object used to create the program.
    renderer: WebGLRenderer

    The current WebGLRenderer instance.

    uniforms: object

    A map of uniform values, identified by the shader uniform names. This allows uniforms to be kept between shader programs.

    • Add a shader addition to the current configuration.

      Parameters

      • addition: ShaderAdditionConfig

        The shader addition to add.

      • Optionalindex: number

        The index at which to insert the addition. If not specified, it will be added at the end.

      Returns void

    • Add a feature to the current configuration.

      Parameters

      • feature: string

        The feature to add.

      Returns void

    • Applies all stored uniform values to the given shader program. This is used to restore uniform state when switching between shader programs, ensuring the new program receives the same uniform values as the previous one.

      Parameters

      Returns void

    • Clear all features from the current configuration.

      Returns void

    • Remove all uniforms.

      Returns void

    • Returns the addition with the given name.

      Parameters

      • name: string

        The name to find.

      Returns ShaderAdditionConfig | null

      The addition, or null if it was not found.

    • Returns the index of a shader addition with the given name.

      Parameters

      • name: string

        The name to find.

      Returns number

      The index of the addition, or -1 if it was not found.

    • Returns a list of shader additions in the current config that have a specific tag.

      Parameters

      • tag: string

        The tag to filter by.

      Returns ShaderAdditionConfig[]

      The shader additions with the tag.

    • Returns a program suite based on the current configuration. If the program does not exist, it is created.

      The suite contains the following properties:

      • program (WebGLProgramWrapper) - The compiled shader program.
      • vao (WebGLVAOWrapper) - The VAO associated with the program.
      • config (object) - The configuration object used to create the program.

      If parallel shader compilation is enabled, the program may not be available immediately. In this case, null is returned.undefined

      Returns Object | null

      The program suite, or null if the program is not available.

    • Remove a shader addition from the current configuration.

      Parameters

      • name: string

        The name of the shader addition to remove.

      Returns void

    • Remove a feature from the current configuration.

      Parameters

      • feature: string

        The feature to remove.

      Returns void

    • Delete a uniform value. While unused uniforms are not harmful, they do take time to process and can be a source of confusion.

      Parameters

      • name: string

        The name of the uniform.

      Returns void

    • Replace a shader addition in the current configuration.

      Parameters

      • name: string

        The name of the shader addition to replace.

      • addition: ShaderAdditionConfig

        The new shader addition.

      Returns void

    • Resets the current configuration object to its default empty state, clearing the base vertex and fragment shaders, all shader additions, and all features.

      Returns void

    • Set the base shader for the current configuration.

      Parameters

      • name: string

        The name of the shader program.

      • vertexShader: string

        The vertex shader source code.

      • fragmentShader: string

        The fragment shader source code.

      Returns void

    • Set the value of a uniform, available for all shader programs in this manager.

      Parameters

      • name: string

        The name of the uniform.

      • value: any

        The value of the uniform.

      Returns void