API

Function updateTexture2DFromPixels

  • Update a rectangular region of an existing Texture2D from a tightly-packed RGBA8 byte buffer.

    The texture must have been created with COPY_DST usage (as createTexture2DFromPixels does). This is the runtime counterpart to createTexture2DFromPixels — for data textures the app mutates each frame / on demand (e.g. a terrain carve heightmap stamped by a dig tool).

    Parameters

    • engine: EngineContext

      Engine context.

    • tex: Texture2D

      Target texture (from createTexture2DFromPixels).

    • data: Uint8Array

      width * height * 4 bytes for the sub-region, row-major, straight alpha.

    • x: number = 0

      Destination origin X in texels (default 0).

    • y: number = 0

      Destination origin Y in texels (default 0).

    • width: number = tex.width

      Region width in texels (default tex.width).

    • height: number = tex.height

      Region height in texels (default tex.height).

    Returns void