← The API

Phaser AE

API docs

v3.0.0-1187 exports in 24 modulesreleased October 14, 2026

ContentsWebGL2

Need to get started? Install the Phaser AE CLI →

Tools

WebGL2

What the WebGL2 backend shares with packs, and the program compiler every pack uses

engine/kernel/src/webgl.ts

Functions

compileGlProgram

function compileGlProgram(gl: WebGL2RenderingContext, vertex: string, fragment: string, label: string): WebGLProgram

From @phaser-ae/kernel

Compile and link a pack's GLSL program; a compile or link error throws with label and the GL log, and leaves nothing behind. A vertex shader with main() and gl_Position is wrapped so its geometry follows WebGPU's edge rule: it gains a uniform and a wrapper main, so it must not declare ae_main or ae_EdgeNudge itself.

glPixelHeight

function glPixelHeight(gl: WebGL2RenderingContext, height: number): void

From @phaser-ae/kernel

WebGL2 backend use: the height in pixels of what it draws into, so every program compileGlProgram made keeps the edge rule. Call it when the target's size changes.

Classes

GlDepthCopy

class GlDepthCopy

From @phaser-ae/kernel

A copy of the scene's depth a pack can sample while the real depth buffer is still attached for drawing (sampling that would be a feedback loop). One per pack; resized on demand.

  • constructor(private readonly gl: WebGL2RenderingContext)
  • copy(bag: WebGl2Bag): WebGLTexture — Copy the full scene depth, restoring both framebuffer bindings and scissor enable.
  • dispose():void — Release the snapshot on game destruction, resize or context loss.

Types

WebGl2Bag

interface WebGl2Bag

From @phaser-ae/kernel

What the WebGL2 backend shares with packs that draw for themselves: the context, the atlas and the scene's targets. A drawer's drawGl receives it. WebGL2 helpers live here, in the kernel, so every pack's program follows one rasterisation rule.

  • gl: WebGL2RenderingContext — The context.
  • atlas: WebGLTexture | null — The atlas texture, premultiplied alpha; null until uploaded.
  • textureOf?(tex: number): WebGLTexture | null — The texture a frame lives in, by its framePlace(i).tex: 0 is atlas, anything else a big picture's texture of its own (null until uploaded). A pack that samples a loaded image itself binds this, and then draws pictures too.
  • width: number — Backing-store width.
  • height: number — Backing-store height.
  • framebuffer?: WebGLFramebuffer — Backend-owned scene framebuffer, before final canvas presentation.
  • color?: WebGLTexture — Scene colour, sampled only when not attached as the active draw destination.
  • depth?: WebGLTexture — Scene depth. Copy before sampling while drawing to the scene framebuffer.
  • logicalWidth: number — Logical screen width.
  • logicalHeight: number — Logical screen height.