WebGLTextureUnitsWrapper
A wrapper for the WebGLRenderingContext's texture units.
It tracks which textures are bound to which units, and provides
binding utilities.
Constructor
new WebGLTextureUnitsWrapper(renderer)
Parameters
| name | type | optional | description |
|---|---|---|---|
| renderer | Phaser.Renderer.WebGL.WebGLRenderer | No | The WebGLRenderer instance that owns this wrapper. |
Scope: static
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L9
Since: 4.0.0
Public Members
renderer
renderer: Phaser.Renderer.WebGL.WebGLRenderer
Description:
The WebGLRenderer instance that owns this wrapper.
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L27
Since: 4.0.0
unitIndices
unitIndices: Array.<number>
Description:
List of the indexes of available texture units.
Used in setting uniforms.
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L45
Since: 4.0.0
units
units: Array.<(Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null)>
Description:
The list of texture units available to the WebGLRenderingContext.
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L36
Since: 4.0.0
Public Methods
bind
<instance> bind(texture, unit, [force], [forceActive])
Description:
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:
| name | type | optional | default | description |
|---|---|---|---|---|
| texture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null | No | The texture to bind, or null to unbind the unit. | |
| unit | number | No | The texture unit to bind the texture to. | |
| force | boolean | Yes | false | If true, it will bind the texture even if it is already bound. |
| forceActive | boolean | Yes | true | 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. |
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L97
Since: 4.0.0
bindUnits
<instance> bindUnits(textures, [force])
Description:
Set specific texture units to specific textures.
The active texture unit may change to accommodate the bindings.
Parameters:
| name | type | optional | default | description |
|---|---|---|---|---|
| textures | Array.<(Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | null | undefined)> | No | |
| force | boolean | Yes | false | If true, it will bind all textures, even if they are already bound. |
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L131
Since: 4.0.0
init
<instance> init()
Description:
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.
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L58
Since: 4.0.0
unbindAllUnits
<instance> unbindAllUnits()
Description:
Unbinds all textures from all texture units.
This will change the active texture unit to 0.
Source: src/renderer/webgl/wrappers/WebGLTextureUnitsWrapper.js#L164
Since: 4.0.0