phaser - v4.0.0-rc.4
    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

    Constructors

    Properties

    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

    The key of the currently active shader program.

    indexBuffer: WebGLBufferWrapper

    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.

    Methods

    • 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

    • Clear all features from the current configuration.

      Returns void

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

      Parameters

      • name: string

        The name to find.

      Returns number

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

      Returns Object

    • 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

    • 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