WebGLRenderingContext.uniform[1234][fi][v]()

このロケールの翻訳が存在しないため、英語バージョンのコンテンツを表示しています。 Help us translate this article!

The WebGLRenderingContext.uniform[1234][fi][v]() methods of the WebGL API specify values of uniform variables.

Many of the functions described here have expanded WebGL 2 interfaces, which can be found under WebGL2RenderingContext.uniform[1234][uif][v]().

Syntax

void gl.uniform1f(location, v0);
void gl.uniform1fv(location, value);
void gl.uniform1i(location, v0);
void gl.uniform1iv(location, value);

void gl.uniform2f(location, v0, v1);
void gl.uniform2fv(location, value);
void gl.uniform2i(location, v0, v1);
void gl.uniform2iv(location, value);

void gl.uniform3f(location, v0, v1, v2);
void gl.uniform3fv(location, value);
void gl.uniform3i(location, v0, v1, v2);
void gl.uniform3iv(location, value);

void gl.uniform4f(location, v0, v1, v2, v3);
void gl.uniform4fv(location, value);
void gl.uniform4i(location, v0, v1, v2, v3);
void gl.uniform4iv(location, value);

Parameters

location
A WebGLUniformLocation object containing the location of the uniform attribute to modify.
value, v0, v1, v2, v3
A new value to be used for the uniform variable. Possible types:
  • A floating point Number for floating point values (methods with "f").
  • A sequence of floating point numbers (for example a Float32Array or an Array of numbers) for floating point vector methods (methods with "fv").
  • An integer Number for integer values (methods with "i").
  • An Int32Array for integer vector methods (methods with "iv").

Return value

None.

Examples

gl.uniform1f(u_alpha, 0.8);

Specifications

Specification Status Comment
WebGL 1.0
The definition of 'uniform' in that specification.
Recommendation Initial definition.
OpenGL ES 2.0
The definition of 'glUniform' in that specification.
Standard Main page of the OpenGL API.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
uniform1fChrome Full support 9Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support 25Firefox Android Full support YesOpera Android Full support 12Safari iOS Full support 8.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support

See also