Note: This feature is available in Web Workers.
The WebGLRenderingContext.getUniform() method of the WebGL API returns the value of a uniform variable at a given location.
getUniform(program, location)programA WebGLProgram containing the uniform attribute.
locationA WebGLUniformLocation object containing the location of the uniform attribute to get.
The returned type depends on the uniform type:Uniform type Returned type WebGL 1 only booleanGLBooleanintGLintfloatGLfloatvec2Float32Array (with 2 elements)ivec2Int32Array (with 2 elements)bvec2Array of GLBoolean (with 2 elements)vec3Float32Array (with 3 elements)ivec3Int32Array (with 3 elements)bvec3Array of GLBoolean (with 3 elements)vec4Float32Array (with 4 elements)ivec4Int32Array (with 4 elements)bvec4Array of GLBoolean (with 4 elements)mat2Float32Array (with 4 elements)mat3Float32Array (with 9 elements)mat4Float32Array (with 16 elements)sampler2DGLintsamplerCubeGLintAdditionally available in WebGL 2 uintGLuintuvec2Uint32Array (with 2 elements)uvec3Uint32Array (with 3 elements)uvec4Uint32Array (with 4 elements)mat2x3Float32Array (with 6 elements)mat2x4Float32Array (with 8 elements)mat3x2Float32Array (with 6 elements)mat3x4Float32Array (with 12 elements)mat4x2Float32Array (with 8 elements)mat4x3Float32Array (with 12 elements)any sampler type GLint
const loc = gl.getUniformLocation(program, "u_foobar");
gl.getUniform(program, loc);