Phaser API Documentation

  Version: 
Filter

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(gl, mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, [pma], [forceSize], [flipY])

Parameters:

name type arguments Default description
gl WebGLRenderingContext

WebGL context the texture belongs to.

mipLevel number

Mip level of the texture.

minFilter number

Filtering of the texture.

magFilter number

Filtering of the texture.

wrapT number

Wrapping mode of the texture.

wrapS number

Wrapping mode of the texture.

format number

Which format does the texture use.

pixels object

pixel data.

width number

Width of the texture in pixels.

height number

Height of the texture in pixels.

pma boolean <optional> true

Does the texture have premultiplied alpha?

forceSize boolean <optional> false

If true it will use the width and height passed to this method, regardless of the pixels dimension.

flipY boolean <optional> false

Sets the UNPACK_FLIP_Y_WEBGL flag the WebGL Texture uses during upload.

Members

<private> __SPECTOR_Metadata: object
Focus
Focus

Description:

Metadata for the SpectorJS tool, set if debug is enabled. You should set this via the spectorMetadata property, which will update the __SPECTOR_Metadata property on the WebGLTexture.

Type:
object
Focus
Focus
flipY: boolean
Focus
Focus

Description:

Sets the UNPACK_FLIP_Y_WEBGL flag the WebGL Texture uses during upload.

Type:
boolean
Focus
Focus
forceSize: boolean
Focus
Focus

Description:

Whether to use the width and height properties, regardless of pixel dimensions.

Type:
boolean
Focus
Focus
format: number
Focus
Focus

Description:

Which format does the texture use.

Type:
number
Focus
Focus
gl: WebGLRenderingContext
Focus
Focus

Description:

The WebGL context this WebGLTexture belongs to.

Type:
WebGLRenderingContext
Focus
Focus
height: number
Focus
Focus

Description:

Height of the texture in pixels.

Type:
number
Focus
Focus
isRenderTexture: boolean
Focus
Focus

Description:

Whether this is used as a RenderTexture.

Type:
boolean
Default: false
Focus
Focus
magFilter: number
Focus
Focus

Description:

Filtering of the texture.

Type:
number
Focus
Focus
minFilter: number
Focus
Focus

Description:

Filtering of the texture.

Type:
number
Focus
Focus
mipLevel: number
Focus
Focus

Description:

Mip level of the texture.

Type:
number
Focus
Focus
<nullable> pixels: object
Focus
Focus

Description:

Pixel data. This is the source data used to create the WebGLTexture.

Type:
object
Focus
Focus
pma: boolean
Focus
Focus

Description:

Does the texture have premultiplied alpha?

Type:
boolean
Focus
Focus
spectorMetadata: object
Focus
Focus

Description:

The __SPECTOR_Metadata property of the WebGLTexture, used to add extra data to the debug SpectorJS integration.

Type:
object
Focus
Focus
<nullable> webGLTexture: WebGLTexture
Focus
Focus

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.

Type:
WebGLTexture
Default: null
Focus
Focus
width: number
Focus
Focus

Description:

Width of the texture in pixels.

Type:
number
Focus
Focus
wrapS: number
Focus
Focus

Description:

Wrapping mode of the texture.

Type:
number
Focus
Focus
wrapT: number
Focus
Focus

Description:

Wrapping mode of the texture.

Type:
number
Focus
Focus

Methods

createResource()
Focus
Focus

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.

Focus
Focus
destroy()
Focus
Focus

Description:

Deletes the WebGLTexture from the GPU, if it has not been already.

Focus
Focus
update(source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format)
Focus
Focus

Description:

Updates the WebGLTexture from an updated source.

This should only be used when the source is a Canvas or Video element.

Parameters:

name type description
source object

The source to update the WebGLTexture with.

width number

The new width of the WebGLTexture.

height number

The new height of the WebGLTexture.

flipY boolean

Should the WebGLTexture set UNPACK_MULTIPLY_FLIP_Y?

wrapS number

The new wrapping mode for the WebGLTexture.

wrapT number

The new wrapping mode for the WebGLTexture.

minFilter number

The new minification filter for the WebGLTexture.

magFilter number

The new magnification filter for the WebGLTexture.

format number

The new format for the WebGLTexture.

Focus
Focus