Skip to content

ImageTexture

Image texture

Helper class storing image as a WebGL texture. Used by shader classes and renderers as wrapper around images providing convenient interfaces.

new ImageTexture(gl, size, grayscale, linear, mipmap): ImageTexture

Constructor

WebGL2RenderingContext

Context where texture is allocated

Size = ...

Size of the image

boolean = false

Whether image is grayscsale or rgb

boolean = false

Whether interpolation is linear or nearest

boolean = false

ImageTexture

protected buffer: null | WebGLTexture = null

Input image texture


protected gl: WebGL2RenderingContext

Context where texture is allocated


protected grayscale: boolean = false

Whether image is grayscsale or rgb


protected levels: number = 0

Number of mipmap levels


protected linear: boolean = false

Whether interpolation is linear or nearest


protected mipmap: boolean = false


protected size: Size

Size of the image

dispose(): void

Dispose allocated resources

void


genLevels(): boolean

Generate mipmap levels if enabled

boolean


isGrayscale(): boolean

Whether texture is grayscale

boolean

True if texture is grayscale


levelCount(): number

Number of mipmap levels

number


levelSize(level): Size

Size of the mipmap level

number

Size


resize(size): boolean

Resize texture

Size

New size of the image

boolean

True when successfully resized, false otherwise


texture(): null | WebGLTexture

Texture instance

null | WebGLTexture

Instance of the texture


textureSize(): Size

Texture size

Size

Size of the texture


update(image): null | WebGLTexture

Update texture

ImageSource

Image to upload into texture

null | WebGLTexture

Updated texture


valid(): boolean

Whether texture is allocated and valid

boolean

True if texture is allocated, false otherwise