Expand Minimize

texParameterf method

Sets texture parameters for the current texture unit.

IE11

Syntax

WebGLRenderingContext.texParameterf(target, pname, param);

Parameters

target [in]

Type: Number

The target texture for the current texture unit. Must be one of the following:

ValueMeaning
gl.TEXTURE_2D

Represents a 2D image.

gl.TEXTURE_CUBE_MAP

The texture is composed of six 2D images, one for each face of a cube.

 

pname [in]

Type: Number

The name of the texture parameter. Use one of the following:

ValueMeaning
gl.TEXTURE_MIN_FILTER

A texture filter constant to use when a surface is rendered smaller than the corresponding texture bitmap (such as for distant objects). Initial value is gl.NEAREST_MIPMAP_LINEAR.

gl.TEXTURE_MAG_FILTER

A texture filter constant to use when a surface is rendered larger than the corresponding texture bitmap (such as for close-up objects). Initial value is gl.LINEAR.

gl.TEXTURE_WRAP_S

Sets the wrap parameter for texture coordinate s to either gl.CLAMP or gl.REPEAT. gl.CLAMP causes s coordinates to be clamped to the range [0,1] and is useful for preventing wrapping artifacts when mapping a single image onto an object. gl.REPEAT causes the integer part of the s coordinate to be ignored; WebGL uses only the fractional part, thereby creating a repeating pattern. Border texture elements are accessed only if wrapping is set to gl.CLAMP. Initially, gl.TEXTURE_WRAP_S is set to gl.REPEAT.

gl.TEXTURE_WRAP_T

Sets the wrap parameter for texture coordinate t to either gl.CLAMP or gl.REPEAT. Initial value is gl.REPEAT.

gl.TEXTURE_MAX_ANISOTROPY_EXT

Use anisotropic filtering. You must call getExtension("gl.TEXTURE_MAX_ANISOTROPY_EXT") first to enable. For more info, see Anisotropic filtering.

 

param [in]

Type: Number

The value of pname.

Return value

This method does not return a value.

Remarks

WebGL errorDescription
gl.INVALID_OPERATIONIf no texture is bound.
gl.INVALID_ENUMIf target, pname, or param values are invalid.

 

The value of param depends on the value of pname. When using floating-point textures, only gl.NEAREST is supported. The following shows possible calling values :

  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
  • texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT)

See also

WebGLRenderingContext

 

 

Show:
© 2014 Microsoft