Documentation
    Preparing search index...

    Class UnlitProgram

    The single pipeline the MVP tier draws with (§120): unlit, flat-coloured, position-only geometry.

    const program = UnlitProgram.create(gl);
    program.use();
    program.setViewProjection(viewProjection); // once per viewport
    program.setModel(item.worldMatrix); // once per draw
    program.setColor(item.material.color);
    program.setFeatures(hasMap, material.vertexColors);

    Owns its GL objects and nothing else. It is not re-created on context loss by itself: the renderer drops its reference when the context goes away and calls UnlitProgram.create again on restore (§61's "re-creates engine-owned GPU resources"), because only the renderer knows which context is the live one.

    Implements

    Index
    • get disposed(): boolean

      Returns boolean

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

      Only call this on a live context. After a context loss every handle is already invalid and the renderer drops its reference instead of disposing — see the class documentation.

      Returns void

    • Uploads a straight-alpha, linear-light RGBA colour (§57, §60a), scaled by the material's opacity. Accepts the material's own live array; the values are copied into scratch, so the material keeps ownership of its array.

      opacity multiplies alpha only — §57 makes it a uniform transparency over whatever alpha the colour already carries — and defaults to 1, at which alpha × 1 is alpha bit for bit, so a material that never touches opacity uploads exactly what it did before the field existed.

      Parameters

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

      Returns void

    • Selects the two optional multipliers for the draw about to be issued (§53's uvs/colors, §57's map, R-19): whether to sample the bound texture, and whether to multiply by the geometry's per-vertex colour.

      program.setFeatures(material.map !== null, material.vertexColors);
      

      Issues a GL call only where the draw changes something. The mirror starts at GL's own initial 0/0, so a scene whose materials name neither feature calls this once per draw and uploads nothing — the compatibility guarantee applyMaterialState makes for §57's render state, made again here for the same reason and checked the same way.

      The map sampler's texture unit is uploaded lazily, the first time this program is asked for a textured draw: glUniform1i writes into the currently bound program, and a sampler upload at creation time would put the renderer's program state in two places (the argument SpriteProgram.setSampler records). GL's initial sampler value is already MAP_TEXTURE_UNIT, so the upload is belt and braces — it costs one call in the lifetime of a program that ever draws a texture, and nothing at all in one that does not.

      Parameters

      • useMap: boolean
      • useVertexColors: boolean

      Returns void

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

      Parameters

      Returns void

    • One-target morph weight in [0, 1] — a no-op on the default unlit program, which has no morphWeight0 uniform.

      Parameters

      • weight: 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).

      Parameters

      Returns void

    • Makes this the current program. Call once per frame, before any upload.

      Returns void

    • Compiles and links the unlit program on gl.

      Throws a FourError carrying SHADER_COMPILATION_FAILED (§89) with the driver's info log in context.log when any stage fails to compile, when linking fails, when GL refuses to allocate an object, or when a uniform this backend wrote is missing from the linked program. Shader objects are deleted on every path — successful or not — because they are only needed until the link completes.

      A single failure code covers compile and link because §89 defines one, and because the two are one operation from a caller's point of view: the program either exists or it does not. context.stage says which half failed.

      Parameters

      Returns UnlitProgram