WebGLRenderingContext.getUniform() - Web APIs 编辑

The WebGLRenderingContext.getUniform() method of the WebGL API returns the value of a uniform variable at a given location.

Syntax

any gl.getUniform(program, location);

Parameters

program
A WebGLProgram containing the uniform attribute.
location
A WebGLUniformLocation object containing the location of the uniform attribute to get.

Return value

The returned type depends on the uniform type:

Uniform typeReturned type
WebGL 1 only
booleanGLBoolean
intGLint
floatGLfloat
vec2Float32Array (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)
sampler2DGLint
samplerCubeGLint
Additionally available in WebGL 2
uintGLuint
uvec2Uint32Array (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 typeGLint

Examples

var loc = gl.getUniformLocation(program, 'u_foobar');
gl.getUniform(program, loc);

Specifications

SpecificationStatusComment
WebGL 1.0
The definition of 'getUniform' in that specification.
RecommendationInitial definition for WebGL.
OpenGL ES 2.0
The definition of 'glGetUniform' in that specification.
StandardMan page of the (similar) OpenGL ES 2 API.
WebGL 2.0
The definition of 'getUniform' in that specification.
Editor's DraftUpdated definition for WebGL.
OpenGL ES 3.0
The definition of 'glGetUniform' in that specification.
StandardMan page of the (similar) OpenGL ES 3 API.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:94 次

字数:9429

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文