@lakuna/ugl
    Preparing search index...

    Class Texture2d

    A two-dimensional texture.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    context: Context

    The rendering context.

    Accessors

    • get isImmutableFormat(): boolean

      Whether or not this is an immutable-format texture.

      Returns boolean

    • get isTextureComplete(): boolean

      Whether or not this texture is texture complete.

      Returns boolean

    Methods

    • Get the dimensions of the mip at the given level.

      Parameters

      • level: number

        The level of the mip.

      Returns number[]

      The width, height (if applicable), and depth (if applicable) of the mip, in that order.

    • Make this texture into an immutable-format texture.

      Parameters

      • Optionallevels: number

        The number of levels in the texture, or undefined for one level.

      • Optionalformat: TextureFormat

        The internal format of the texture, or undefined to keep the current format (defaults to RGBA).

      • Optionaldims: number[]

        The dimensions of the texture, or undefined to keep the current dimensions.

      Returns void

      TextureFormatError if the given format is unsized.

      BadValueError if the given dimensions are too small for the given number of levels.

    • Copy the data in a framebuffer into one of this texture's mips.

      Parameters

      • framebuffer: null | Framebuffer

        The framebuffer to copy into the mip, or null for the default framebuffer.

      • Optionallevel: number

        The level of the mip within its mipmap. Defaults to the top mip.

      • Optionalface: CubeFace

        The mipmap that the mip belongs to. Ignored by non-cubemap textures.

      • Optionalbounds: Rectangle | Prism

        The bounds of the mip to be updated. Defaults to the entire mip if not set.

      • Optionaltype: TextureDataType

        The type of the given data. Must be compatible with the format of the given data.

      • OptionalunpackAlignment: 1 | 2 | 4 | 8

        The alignment to use when unpacking the data, or undefined to let this be automatically determined.

      • Optionalarea: Rectangle | Prism

        The area of the framebuffer to copy into the mip.

      Returns void

      TextureFormatError if the given data type is incompatible with this texture's format.

    • Copy the data in a buffer into one of this texture's mips.

      Parameters

      • buffer: VertexBuffer

        The buffer to copy into the mip.

      • level: undefined | number

        The level of the mip within its mipmap. Defaults to the top mip.

      • face: undefined | CubeFace

        The mipmap that the mip belongs to. Ignored by non-cubemap textures.

      • bounds: undefined | Rectangle | Prism

        The bounds of the mip to be updated. Defaults to the entire mip if not set.

      • type: undefined | TextureDataType

        The type of the given data. Must be compatible with the format of the given data.

      • unpackAlignment: undefined | 1 | 2 | 4 | 8

        The alignment to use when unpacking the data, or undefined to let this be automatically determined.

      • size: number

        The number of bytes of data to copy from the buffer.

      • offset: number

        The offset in bytes from the start of the buffer to start copying at.

      Returns void

      TextureFormatError if the given data type is incompatible with this texture's format.

    • Copy data into one of this texture's mips.

      Parameters

      • Optionaldata: TexImageSource

        The data to copy into the mip.

      • Optionallevel: number

        The level of the mip within its mipmap. Defaults to the top mip.

      • Optionalface: CubeFace

        The mipmap that the mip belongs to. Ignored by non-cubemap textures.

      • Optionalbounds: Rectangle | Prism

        The bounds of the mip to be updated. Defaults to the entire mip if not set.

      • Optionaltype: TextureDataType

        The type of the given data. Must be compatible with the format of the given data.

      • OptionalunpackAlignment: 1 | 2 | 4 | 8

        The alignment to use when unpacking the data, or undefined to let this be automatically determined.

      Returns void

      TextureFormatError if the given data type is incompatible with this texture's format.

    • Copy the data in an array into one of this texture's mips.

      Parameters

      • array: ArrayBufferView

        The array to copy into the mip.

      • Optionallevel: number

        The level of the mip within its mipmap. Defaults to the top mip.

      • Optionalface: CubeFace

        The mipmap that the mip belongs to. Ignored by non-cubemap textures.

      • Optionalbounds: Rectangle | Prism

        The bounds of the mip to be updated. Defaults to the entire mip if not set.

      • Optionaltype: TextureDataType

        The type of the given data. Must be compatible with the format of the given data.

      • OptionalunpackAlignment: 1 | 2 | 4 | 8

        The alignment to use when unpacking the data, or undefined to let this be automatically determined.

      • Optionaloffset: number

        The offset from the start of the array to start copying at, or undefined for the start of the array.

      • Optionallength: number

        The number of elements to copy from the array, or undefined for the entire array.

      Returns void

      TextureFormatError if the given data type is incompatible with this texture's format.

    • Create a two-dimensional texture from the data in the image at the given URL. The texture is initially filled with magenta and is later filled with the image once it loads.

      Parameters

      • context: Context

        The rendering context of the texture.

      • url: string

        The URL of the image.

      Returns Texture2d

      The texture.

    • Create a two-dimensional texture from the data in the image at the given URL.

      Parameters

      • context: Context

        The rendering context of the texture.

      • url: string

        The URL of the image.

      Returns Promise<Texture2d>

      The texture.