Phaser API Documentation

  Version: 
addGLTexture(key, glTexture, [width], [height])

Description:

Takes a WebGL Texture and creates a Phaser Texture from it, which is added to the Texture Manager using the given key.

This allows you to then use the Texture as a normal texture for texture based Game Objects like Sprites.

If the width and height arguments are omitted, but the WebGL Texture was created by Phaser's WebGL Renderer and has glTexture.width and glTexture.height properties, these values will be used instead.

This is a WebGL only feature.

Parameters:

name type arguments description
key string

The unique string-based key of the Texture.

glTexture WebGLTexture

The source Render Texture.

width number <optional>

The new width of the Texture. Read from glTexture.width if omitted.

height number <optional>

The new height of the Texture. Read from glTexture.height if omitted.

Returns:
Description:

The Texture that was created, or null if the key is already in use.

Since: 3.19.0