PokéRogue
    Preparing search index...

    Class WebGLTextureUnitsWrapper

    A wrapper for the WebGLRenderingContext's texture units. It tracks which textures are bound to which units, and provides binding utilities.

    Index
    renderer: WebGLRenderer

    The WebGLRenderer instance that owns this wrapper.

    unitIndices: number[]

    List of the indexes of available texture units. Used in setting uniforms.

    units: (WebGLTextureWrapper | null)[]

    The list of texture units available to the WebGLRenderingContext.

    • Binds a texture to a texture unit.

      This will change the active texture unit to the given unit, unless forceActive is false.

      This should be the only way to bind a texture to a unit.

      Parameters

      • texture: WebGLTextureWrapper | null

        The texture to bind, or null to unbind the unit.

      • unit: number

        The texture unit to bind the texture to.

      • Optionalforce: boolean

        If true, it will bind the texture even if it is already bound. Default false.

      • OptionalforceActive: boolean

        If true, it will change the active texture unit to the given unit even if it is already active. Otherwise, it will only change the active texture unit if it is not already active. Default true.

      Returns void

    • Set specific texture units to specific textures.

      The active texture unit may change to accommodate the bindings.

      Parameters

      • textures: (WebGLTextureWrapper | null | undefined)[]

        The textures to bind. Null values will be unbound. Undefined values will be skipped.

      • Optionalforce: boolean

        If true, it will bind all textures, even if they are already bound. Default false.

      Returns void

    • Initializes the texture units to null. The active texture unit will be 0 after this runs.

      This populates every texture unit with a 1x1 texture. This stops WebGL errors on MacOS. These textures are not wrapped, and are not intended to be used, so the texture units are recorded as null.

      Returns void

    • Unbinds all textures from all texture units. This will change the active texture unit to 0.

      Returns void

    • Unbinds a specific texture from all texture units it is currently bound to.

      Iterates over all texture units and replaces any binding that matches the given texture with null. This is typically called when a texture is about to be destroyed, to ensure no unit holds a stale reference.

      Parameters

      Returns void