{{APIRef("WebGL")}} {{SeeCompatTable}}
The WebGLSampler
interface is part of the WebGL 2 API and stores sampling parameters for {{domxref("WebGLTexture")}} access inside of a shader.
When working with WebGLSampler
objects, the following methods of the {{domxref("WebGL2RenderingContext")}} are useful:
- {{domxref("WebGL2RenderingContext.createSampler()")}}
- {{domxref("WebGL2RenderingContext.deleteSampler()")}}
- {{domxref("WebGL2RenderingContext.isSampler()")}}
- {{domxref("WebGL2RenderingContext.bindSampler()")}}
- {{domxref("WebGL2RenderingContext.getSamplerParameter()")}}
Examples
Creating a WebGLSampler
object
in this example, gl
must be a {{domxref("WebGL2RenderingContext")}}. WebGLSampler
objects are not available in WebGL 1.
var sampler = gl.createSampler();
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('WebGL2', "#3.3", "WebGLSample")}} | {{Spec2('WebGL2')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatNo}} [2] | {{CompatNightly}} [1] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
[1] WebGL 2 is enabled by default in Firefox Nightly. To enable it in a release version of Firefox, set the preference webgl.enable-prototype-webgl2
to true
in about:config.
[2] To use an experimental implementation of WebGL 2 in Chrome, you have to start Chrome with the runtime flag --enable-unsafe-es3-apis
.