Class Texture

A texture class contains image data for use in a shader. Along with the image data, the texture contains state variable that determine how secondary conditions, like wrapping and interpolation work.

Constructors

Properties

anisotropy: number

The anistropic filtering level for the texture.

0
data: null | Float32Array
flipY: boolean

Whether to flip the Y direction of the texture

format: number

The texture format.

gl.RGBA
generateMipmaps: boolean

Whether to generate mip maps for this texture. This requires that the texture be power of 2 in size

true

The WTCGL rendering context.

A local reference to the renderer state

height: number

The height of the texture.

id: number

A unique ID for the texture object, allows us to determine whether a texture has already been bound or not.

image: ImageTypes | ImageTypes[]

The image element representing the texture. Can be an HTML image, video, or canvas

internalFormat: number

the texture internal format.

gl.RGBA
level: number

A GLint specifying the level of detail. Level 0 is the base image level and level n is the nth mipmap reduction level. Only relevant if we have mipmaps.

0
magFilter: number

The filter to use when rendering larger.

minFilter: number

The filter to use when rendering smaller.

needsUpdate: boolean

Whether the texture needs an update in memory

premultiplyAlpha: boolean

Whether the texture is interpolated as having premultiplied alpha.

false

Texture state, contains the basic texture properties.

store: {
    image?: ImageTypes | ImageTypes[];
}

The image store

target: number

The binding point for the texture.

gl.TEXTURE_2D
texture: WebGLTexture

The WebGL texture object containing the data and state for WebGL

type: number

The texture type. Typically one of gl.UNSIGNED_BYTE, gl.FLOAT, ext.HALF_FLOAT_OES

gl.UNSIGNED_BYTE
unpackAlignment:
    | 1
    | 2
    | 4
    | 8

The unpack alignment for pixel stores.

width: number

The width of the texture.

wrapS: number

Wrapping. Normally one of gl.CLAMP_TO_EDGE, gl.REPEAT, gl.MIRRORED REPEAT

gl.CLAMP_TO_EDGE
wrapT: number

Wrapping. Normally one of gl.CLAMP_TO_EDGE, gl.REPEAT, gl.MIRRORED REPEAT

gl.CLAMP_TO_EDGE

Methods

  • Bind the texture. Skips over if it's determined that the texture is already bound.

    Returns void

  • Update the texture in graphics memory to the internal image and perform various state updates on an as-needs basis.

    Parameters

    • textureUnit: number = 0

      The texture unit to update against.

    Returns void