Skip to main content
Version: Phaser v4.0.0-rc.6

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

nametypeoptionaldefaultdescription
rendererPhaser.Renderer.WebGL.WebGLRendererNoThe WebGLRenderer instance that owns this wrapper.
mipLevelnumberNoMip level of the texture.
minFilternumberNoFiltering of the texture.
magFilternumberNoFiltering of the texture.
wrapTnumberNoWrapping mode of the texture.
wrapSnumberNoWrapping mode of the texture.
formatnumberNoWhich format does the texture use.
pixelsobjectNopixel data.
widthnumberNoWidth of the texture in pixels.
heightnumberNoHeight of the texture in pixels.
pmabooleanYestrueDoes the texture have premultiplied alpha?
forceSizebooleanYesfalseIf true it will use the width and height passed to this method, regardless of the pixels dimension.
flipYbooleanYestrueSets 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:

nametypeoptionaldescription
widthnumberNoThe new width of the WebGLTexture.
heightnumberNoThe 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:

nametypeoptionaldescription
sourceobjectNoThe source to update the WebGLTexture with.
widthnumberNoThe new width of the WebGLTexture.
heightnumberNoThe new height of the WebGLTexture.
flipYbooleanNoShould the WebGLTexture set UNPACK_MULTIPLY_FLIP_Y?
wrapSnumberNoThe new wrapping mode for the WebGLTexture.
wrapTnumberNoThe new wrapping mode for the WebGLTexture.
minFilternumberNoThe new minification filter for the WebGLTexture.
magFilternumberNoThe new magnification filter for the WebGLTexture.
formatnumberNoThe new format for the WebGLTexture.

Source: src/renderer/webgl/wrappers/WebGLTextureWrapper.js#L279
Since: 3.80.0