GLSampler

A WebGL Sampler object stores texture sampling information, such as filtering and repeat properties, so that different sampling properties can be applied to the same texture. This object requires WebGL2.

Constructor

new L3D.GLSampler(gl, options)

Parameters
gl GLContext
options Object

Optional configuration for the sampler.

Properties
minFilter number GL.LINEAR
magFilter number GL.LINEAR
filter number

Sets both minFilter and magFilter to the same value.

wrapS number GL.REPEAT
wrapT number GL.REPEAT
wrapR number GL.REPEAT
wrap number

Sets both wrapS and wrapT to the same value.

Properties

handle WebGLSampler

The WebGL handle for the sampler object, null if it hasn't been created.

isValid bool

True if the sampler object has been created.

magFilter number = GL.LINEAR

The magnification filter type. Can be: GL.NEAREST, or GL.LINEAR.

minFilter number = GL.LINEAR

The minification filter type. Can be: GL.NEAREST, GL.LINEAR, GL.LINEAR_MIPMAP_LINEAR, GL.LINEAR_MIPMAP_NEAREST, GL.NEAREST_MIPMAP_LINEAR, or GL.NEAREST_MIPMAP_NEAREST.

mipmap bool = false

True if the filtering requires the texture to have a mipmap. Setting this property will change the minFilter.

wrapR number = GL.REPEAT

The wrapR type. Can be: GL.REPEAT, GL.CLAMP_TO_EDGE, or GL.MIRRORED_REPEAT

wrapS number = GL.REPEAT

The wrapS type. Can be: GL.REPEAT, GL.CLAMP_TO_EDGE, or GL.MIRRORED_REPEAT

wrapT number = GL.REPEAT

The wrapT type. Can be: GL.REPEAT, GL.CLAMP_TO_EDGE, or GL.MIRRORED_REPEAT

Methods

bind(textureUnit)

Bind the sampler to the given texture unit.

Parameters
textureUnit number

The texture unit index, starting from 0.

configure(options)

Set the properties of the sampler object.

Parameters
options Object
Properties
minFilter number GL.LINEAR
magFilter number GL.LINEAR
filter number

Sets both minFilter and magFilter to the same value.

wrapS number GL.REPEAT
wrapT number GL.REPEAT
wrapR number GL.REPEAT
wrap number

Sets wrapS, wrapT, and wrapR to the same value.

create()

Create the sampler object.

destroy()

Destroy the sampler object.

unbind(textureUnit)

Set the sampler object assigned to the texture unit to null.

Parameters
textureUnit number

The texture unit index, starting from 0.

update()

Apply the properties to the sampler object.