Creates a WebGL context without a window for headless rendering and server-side graphics
Overall
score
96%
A utility for managing texture sampling configurations in WebGL 2, allowing dynamic switching between different filtering modes without modifying texture parameters.
@generates
/**
* Creates and configures a sampler object with specified filtering parameters.
*
* @param {WebGL2RenderingContext} gl - The WebGL 2 rendering context.
* @param {Object} options - Configuration options for the sampler.
* @param {number} options.minFilter - Minification filter (e.g., gl.NEAREST, gl.LINEAR).
* @param {number} options.magFilter - Magnification filter (e.g., gl.NEAREST, gl.LINEAR).
* @param {number} [options.wrapS] - S-coordinate wrapping mode (default: gl.CLAMP_TO_EDGE).
* @param {number} [options.wrapT] - T-coordinate wrapping mode (default: gl.CLAMP_TO_EDGE).
* @returns {WebGLSampler} The created sampler object.
*/
function createSampler(gl, options) {
// IMPLEMENTATION HERE
}
/**
* Binds a sampler object to a specified texture unit.
*
* @param {WebGL2RenderingContext} gl - The WebGL 2 rendering context.
* @param {number} unit - The texture unit index (0-based).
* @param {WebGLSampler} sampler - The sampler object to bind.
*/
function bindSampler(gl, unit, sampler) {
// IMPLEMENTATION HERE
}
/**
* Updates a sampler's filtering parameters.
*
* @param {WebGL2RenderingContext} gl - The WebGL 2 rendering context.
* @param {WebGLSampler} sampler - The sampler object to update.
* @param {number} minFilter - New minification filter.
* @param {number} magFilter - New magnification filter.
*/
function updateSamplerFilters(gl, sampler, minFilter, magFilter) {
// IMPLEMENTATION HERE
}
/**
* Deletes a sampler object and releases its resources.
*
* @param {WebGL2RenderingContext} gl - The WebGL 2 rendering context.
* @param {WebGLSampler} sampler - The sampler object to delete.
*/
function deleteSampler(gl, sampler) {
// IMPLEMENTATION HERE
}
module.exports = {
createSampler,
bindSampler,
updateSamplerFilters,
deleteSampler,
};Provides headless WebGL 2 rendering context for server-side graphics operations.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-gldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10