Documentation
    Preparing search index...

    Class SpriteProgram

    The textured-quad pipeline (§55) — the backend's second and last program in the §106a tier.

    const program = SpriteProgram.create(gl);
    program.use();
    program.setSampler(0); // once per activation
    program.setViewProjection(viewProjection); // once per viewport
    program.setModel(item.worldMatrix); // once per draw
    program.setTint(item.material.tint);

    It shares gl-geometry.ts's vertex arrays with UnlitProgram: both declare the position stream at POSITION_ATTRIBUTE_LOCATION and the uv stream at UV_ATTRIBUTE_LOCATION. Sprite authors the atlas cell onto that stream; this program interpolates it.

    Owns its GL objects and nothing else — the texture it samples belongs to gl-texture.ts's cache, and the renderer re-creates this program on context restore exactly as it re-creates the unlit one (§61).

    Implements

    Index
    • get disposed(): boolean

      Whether SpriteProgram.dispose has run.

      Returns boolean

    • Deletes the GL program (§83). Idempotent.

      Only call this on a live context — see UnlitProgram.dispose.

      Returns void

    • Uploads one render item's world matrix. See setViewProjection.

      Parameters

      Returns void

    • Points the map sampler at texture unit.

      Uploaded whenever the pipeline becomes current rather than once at creation: glUniform* writes into the currently bound program, and binding one at creation time would leave the renderer's program state to be guessed at from two places instead of one (decision, WP-3a.3). One uniform1i per pipeline switch is not a cost worth optimizing.

      Parameters

      • unit: number

      Returns void

    • Uploads a straight-alpha RGBA tint (§55, §66) scaled by the material's opacity — see UnlitProgram.setColor for the multiply and why the default reproduces the previous upload exactly. Accepts the material's own live array; the values are copied into scratch, so the material keeps ownership of its array.

      Parameters

      • tint: readonly [number, number, number, number]
      • Optionalopacity: number

      Returns void

    • Uploads projection * view for the viewport being drawn. Column-major, so transpose is false — the engine's Matrix4 layout is already GL's (§7b).

      Uniform values live in the program object, so one upload per viewport holds for every sprite drawn into it, even if the unlit pipeline draws in between.

      Parameters

      Returns void

    • Makes this the current program. Call before any upload below.

      Returns void

    • Compiles and links the sprite program on gl.

      Fails exactly as UnlitProgram.create does — see it, and createLinkedProgram, for the contract; the messages name "sprite" instead of "unlit" and the §89 code is the same.

      Parameters

      Returns SpriteProgram