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 | pixel data. | |
| 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#L201
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#L179
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#L170
Since: 3.80.0
format
format: number
Description:
Which format does the texture use.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L125
Since: 3.80.0
height
height: number
Description:
Height of the texture in pixels.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L152
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:
Filtering of the texture.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L98
Since: 3.80.0
minFilter
minFilter: number
Description:
Filtering of the texture.
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#L134
Since: 3.80.0
pma
pma: boolean
Description:
Does the texture have premultiplied alpha?
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L161
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#L397
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#L143
Since: 3.80.0
wrapS
wrapS: number
Description:
Wrapping mode of the texture.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L116
Since: 3.80.0
wrapT
wrapT: number
Description:
Wrapping mode of the texture.
Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L107
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#L321
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#L218
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#L422
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.
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#L257
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_MULTIPLY_FLIP_Y? |
| 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#L279
Since: 3.80.0