Skip to main content
Version: Phaser v4.0.0

Phaser.Textures.Parsers

Scope: static

Source: src/textures/parsers/index.js#L7

Static functions

KTXParser

<static> KTXParser(data)

Description:

Parses a KTX (Khronos Texture) format Compressed Texture file and extracts the texture data required to upload it to WebGL. KTX is a container format for GPU-compressed textures that supports formats such as ETC, ASTC, S3TC, and PVRTC.

The parser validates the 12-byte KTX file identifier, confirms the texture uses a compressed format (uncompressed KTX files are not supported), then reads the image dimensions, internal GL format, and all available mipmap levels from the binary data.

Parameters:

nametypeoptionaldescription
dataArrayBufferNoThe raw binary ArrayBuffer of the KTX file, as loaded by the Compressed Texture File Loader.

Returns: Phaser.Types.Textures.CompressedTextureData - A CompressedTextureData object containing the mipmap levels, dimensions, and internal GL format, ready for WebGL upload.

Source: src/textures/parsers/KTXParser.js#L7
Since: 3.60.0


PCTDecode

<static> PCTDecode(text)

Description:

Decodes a Phaser Compact Texture Atlas (PCT) file from its raw text representation into a structured object.

This is a standalone helper used by both the PCT atlas loader and the PCT texture parser. It converts the line-oriented PCT text format into an object containing a pages array (one entry per atlas page), a folders dictionary, and a frames map with fully-resolved frame names and positions. Frame page indices map directly to the pages array.

The function validates the version header and rejects files with an unsupported major version or a missing PCT: header, returning null in those cases after logging a warning. Unknown line prefixes introduced in future minor versions are silently skipped, as required by the specification.

See the Phaser Compact Texture Atlas Format Specification document for a full description of the format and the semantics of the returned object.

Parameters:

nametypeoptionaldescription
textstringNoThe raw text contents of a .pct file.

Returns: Object - The decoded PCT structure, or null if the input is invalid.

Source: src/textures/parsers/PCTDecode.js#L129
Since: 4.0.0


PVRParser

<static> PVRParser(data)

Description:

Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it.

Parameters:

nametypeoptionaldescription
dataArrayBufferNoThe raw binary ArrayBuffer of the PVR file, as provided by the Compressed Texture File Loader.

Returns: Phaser.Types.Textures.CompressedTextureData - A parsed compressed texture data object containing the mipmap levels, base dimensions, WebGL internal format, and flags indicating it is compressed and does not require mipmap generation.

Source: src/textures/parsers/PVRParser.js#L236
Since: 3.60.0


verifyCompressedTexture

<static> verifyCompressedTexture(data)

Description:

Verify whether the given compressed texture data is valid.

Compare the dimensions of each mip layer to the rules for that specific format.

Mip layer size is assumed to have been calculated correctly during parsing.

Parameters:

nametypeoptionaldescription
dataPhaser.Types.Textures.CompressedTextureDataNoThe compressed texture data to verify.

Returns: boolean - Whether the compressed texture data is valid.

Source: src/textures/parsers/VerifyCompressedTexture.js#L9
Since: 3.80.0