Texture

Texture

Texture class manage TEXTURE_2D types textures

Constructor

new Texture(gl, formatopt)

Parameters:
Name Type Attributes Default Description
gl WebGLRenderingContext webgl context the texture belongs to
format GLenum <optional>
GL_RGB the pixel format, default to gl.RGB (can be gl.RGB, gl.RGBA, gl.LUMINANCE...)
Source:

Methods

bind(unitopt)

Bind the texture
Parameters:
Name Type Attributes Description
unit uint <optional>
optional texture unit to make active before binding
Source:

clamp()

Set both WRAP_S and WRAP_T property to gl.CLAMP_TO_EDGE
Source:

dispose()

delete the webgl texture
Source:

fromData(width, height, dataopt, dataTypeopt)

Allocate texture to the given size, with optional data (TypedArray) and data type
Parameters:
Name Type Attributes Default Description
width number the new texture's width
height number the new texture's height
data TypedArray <optional>
null TypedArray of texture data, can be null
dataType GLenum <optional>
GL_UNSIGNED_BYTE can be gl.UNSIGNED_BYTE, gl.FLOAT, half.HALF_FLOAT_OES etc depending on available extensions
Source:

fromImage(img)

set texture data from html source
Parameters:
Name Type Description
img TexImageSource the source. Can be ImageBitmap, ImageData, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
Source:

mirror()

Set both WRAP_S and WRAP_T property to gl.MIRRORED_REPEAT
Source:

repeat()

Set both WRAP_S and WRAP_T property to gl.REPEAT
Source:

setFilter(smoothopt, mipmapopt, miplinearopt)

Change the filtering parameters
Parameters:
Name Type Attributes Default Description
smooth boolean <optional>
false if true, use LINEAR filtering
mipmap boolean <optional>
false if true, enable mipmaping
miplinear boolean <optional>
false if true, use linear Mipmapping
Source:

wrap(wrap)

Set both WRAP_S and WRAP_T property to the given value
Parameters:
Name Type Description
wrap GLenum the wrap enum
Source: