gophergfx
    Preparing search index...

    Class Texture

    Represents an image texture

    Texture

    Hierarchy (View Summary)

    Index
    • Create a new instance of a texture.

      Parameters

      • source: string | ImageData | null = ...

      Returns Texture

    gl: WebGL2RenderingContext
    height: number | undefined

    The height of the original (non-mipmapped) texture image data or 'undefined' if the image has not yet completed loading.

    texture: WebGLTexture | null

    The internal object used by WebGL to draw this texture -- provides each texture a unique id.

    width: number | undefined

    The width of the original (non-mipmapped) texture image data or 'undefined' if the image has not yet completed loading.

    • Callback function for image loaded events

      Parameters

      • image: HTMLImageElement

        HTML DOM image element produced by loading the image texture

      • url: string

        Original URL the image was loaded from (used as an internal identifier for the image asset)

      Returns void

    • Callback function for when the requested image cannot be found (load error)

      Parameters

      • url: string

        Original URL the image was loaded from (used as an internal identifier for the errored image asset)

      Returns void

    • Load an image into this texture.

      Parameters

      • url: string

        URL to load the texture from (can be absolute, e.g. "http://unlikely-url.com/some-image.jpg", or relative, e.g. "./some-image.jpg"). Can be null to start out with, in which case the texture will be empty.

      Returns void

    • Copies the pixel data from an ImageData source into the texture

      Parameters

      • imageData: ImageData

        An ImageData object with the same width and height as the texture

      Returns void

    • Control the magnification filter (sampling if a texture is shown at greater than its original size)

      Parameters

      • linear: boolean

        Use linear filtering

      Returns void

    • Control the minification filter (sampling if a texture is shown at less than its original size)

      Parameters

      • linear: boolean

        Use linear filtering

      • mipmap: boolean

        Use mipmapping

      Returns void

    • Copies the pixel data from an ImageData source into a portion of the texture, placing it as a sub-image within the texture

      Parameters

      • imageData: ImageData

        An ImageData object with width and height that are the same size or smaller than the texture

      • xOffset: number

        An offset in the x-direction within the texture where the top-left corner of imageData should be placed

      • yOffset: number

        An offset in the y-direction within the texture where the top-left corner of imageData should be placed

      Returns void

    • Set the wrapping mode for the texture.

      Parameters

      • repeat: boolean

        Repeat the texture beyond its bounds or just show it once

      Returns void