melonJS
    Preparing search index...

    Class Texture2dAbstract

    Abstract base for a user-constructed 2D texture asset — an object that owns a drawable image source and can be used anywhere the engine expects an image: Sprite#image, Sprite#normalMap, an ImageLayer, or bound as a sampler uniform in a custom GLShader.

    A Texture2d is recognized by the renderables via instanceof and resolved to its backing canvas/image through Texture2d#getTexture — so passing the asset object directly ({ image: myTexture }) works the same as passing a raw HTMLCanvasElement. Raw DOM image/canvas sources and the loader's decoded CompressedImage data are accepted too, but are not part of this class hierarchy.

    Concrete implementations:

    A future WebGPU implementation would back Texture2d#getTexture with a GPUTexture-wrapping surface rather than an HTMLCanvasElement.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Release any GPU/CPU resources held by this texture. The texture must not be used after calling destroy. No-op by default — subclasses override when they own resources (a baked canvas, a cached GL texture, a pooled render target).

      Returns void