Skip to main content

Function: createTextureFromImage()

createTextureFromImage(gl, image, pixelated?, tile?): WebGLTexture

Defined in: rendering/shaders/utils/create-texture-from-image.ts:14

Creates a WebGL texture from an image.

Parameters

gl

WebGL2RenderingContext

The WebGL2 rendering context.

image

TexImageSource

The image source to create the texture from.

pixelated?

boolean = false

Samples with nearest-neighbor filtering for crisp, blocky scaling, appropriate for pixel-art assets. Defaults to false.

tile?

boolean = false

Wraps with REPEAT on both axes instead of CLAMP_TO_EDGE, for a texture meant to tile across a surface rather than a sprite frame (which must never bleed into a neighboring frame in the same atlas). Defaults to false.

Returns

WebGLTexture

The created WebGL texture.