WebGLTextureWrapper
Wrapper for a WebGL texture, containing all the information that was used to create it.
A WebGLTexture should never be exposed outside the WebGLRenderer, so the WebGLRenderer can handle context loss and other events without other systems having to be aware of it. Always use WebGLTextureWrapper instead.
Constructor
new WebGLTextureWrapper(renderer, mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, [pma], [forceSize], [flipY])
Parameters
| name | type | optional | default | description |
|---|---|---|---|---|
| renderer | Phaser.Renderer.WebGL.WebGLRenderer | No | The WebGLRenderer instance that owns this wrapper. | |
| mipLevel | number | No | Mip level of the texture. | |
| minFilter | number | No | Filtering of the texture. | |
| magFilter | number | No | Filtering of the texture. | |
| wrapT | number | No | Wrapping mode of the texture. | |
| wrapS | number | No | Wrapping mode of the texture. | |
| format | number | No | Which format does the texture use. | |
| pixels | object | No | The pixel data used to populate the texture. Can be a Canvas, Video, ImageData, Uint8Array, or compressed texture object. | |
| width | number | No | Width of the texture in pixels. | |
| height | number | No | Height of the texture in pixels. | |
| pma | boolean | Yes | true | Does the texture have premultiplied alpha? |
| forceSize | boolean | Yes | false | If true it will use the width and height passed to this method, regardless of the pixels dimension. |
| flipY | boolean | Yes | true | Sets the UNPACK_FLIP_Y_WEBGL flag the WebGL Texture uses during upload. |
Scope: static
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L10
Since: 3.80.0
Public Members
batchUnit
batchUnit: number
Description:
The texture unit this texture will be bound to in the current rendering batch.
This should be set by the batcher. It is a quick way to tell whether this texture has been included in the batch. If it is -1, it has not.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L207
Since: 4.0.0
flipY
flipY: boolean
Description:
Sets the UNPACK_FLIP_Y_WEBGL flag the WebGL Texture uses during upload.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L185
Since: 3.80.0
forceSize
forceSize: boolean
Description:
Whether to use the width and height properties, regardless of pixel dimensions.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L176
Since: 3.80.0
format
format: number
Description:
The WebGL pixel format of the texture (e.g. gl.RGBA or gl.RGB).
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L131
Since: 3.80.0
height
height: number
Description:
Height of the texture in pixels.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L158
Since: 3.80.0
isRenderTexture
isRenderTexture: boolean
Description:
Whether this is used as a RenderTexture.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L70
Since: 3.80.0
magFilter
magFilter: number
Description:
The magnification filter for the texture, as a WebGL filter constant (e.g. gl.LINEAR or gl.NEAREST). Applied when the texture is scaled up.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L100
Since: 3.80.0
minFilter
minFilter: number
Description:
The minification filter for the texture, as a WebGL filter constant (e.g. gl.LINEAR or gl.NEAREST). Applied when the texture is scaled down.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L89
Since: 3.80.0
mipLevel
mipLevel: number
Description:
Mip level of the texture.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L80
Since: 3.80.0
pixels
pixels: object
Description:
Pixel data. This is the source data used to create the WebGLTexture.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L140
Since: 3.80.0
pma
pma: boolean
Description:
Does the texture have premultiplied alpha?
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L167
Since: 3.80.0
renderer
renderer: Phaser.Renderer.WebGL.WebGLRenderer
Description:
The WebGLRenderer this WebGLTexture belongs to.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L47
Since: 4.0.0
spectorMetadata
spectorMetadata: object
Description:
The __SPECTOR_Metadata property of the WebGLTexture, used to add extra data to the debug SpectorJS integration.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L418
Since: 3.80.0
webGLTexture
webGLTexture: WebGLTexture
Description:
The WebGLTexture that this wrapper is wrapping.
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.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L56
Since: 3.80.0
width
width: number
Description:
Width of the texture in pixels.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L149
Since: 3.80.0
wrapS
wrapS: number
Description:
The wrapping mode for the S (horizontal) axis of the texture, as a WebGL wrap constant (e.g. gl.REPEAT or gl.CLAMP_TO_EDGE).
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L121
Since: 3.80.0
wrapT
wrapT: number
Description:
The wrapping mode for the T (vertical) axis of the texture, as a WebGL wrap constant (e.g. gl.REPEAT or gl.CLAMP_TO_EDGE).
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L111
Since: 3.80.0
Public Methods
_processTexture
<instance> _processTexture()
Description:
Set all parameters of this WebGLTexture per the stored values.
Access: protected
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L342
Since: 4.0.0
createResource
<instance> createResource()
Description:
Creates a WebGLTexture from the given parameters.
This is called automatically by the constructor. It may also be called again if the WebGLTexture needs re-creating.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L224
Since: 3.80.0
destroy
<instance> destroy()
Description:
Deletes the WebGLTexture from the GPU, if it has not been already.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L443
Since: 3.80.0
resize
<instance> resize(width, height)
Description:
Resizes the WebGLTexture to the new dimensions. This will destroy the contents of the texture.
Wrap mode will be updated: REPEAT if the new size is power-of-two, CLAMP_TO_EDGE if not.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| width | number | No | The new width of the WebGLTexture. |
| height | number | No | The new height of the WebGLTexture. |
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L263
Since: 4.0.0
update
<instance> update(source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format)
Description:
Updates the WebGLTexture from an updated source.
This should only be used when the source is a Canvas or Video element.
Because textures usually change into something complex and unique, this method forces all properties to update without checking.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| source | object | No | The source to update the WebGLTexture with. |
| width | number | No | The new width of the WebGLTexture. |
| height | number | No | The new height of the WebGLTexture. |
| flipY | boolean | No | Should the WebGLTexture set UNPACK_FLIP_Y_WEBGL? |
| wrapS | number | No | The new wrapping mode for the WebGLTexture. |
| wrapT | number | No | The new wrapping mode for the WebGLTexture. |
| minFilter | number | No | The new minification filter for the WebGLTexture. |
| magFilter | number | No | The new magnification filter for the WebGLTexture. |
| format | number | No | The new format for the WebGLTexture. |
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L300
Since: 3.80.0