大网数据广告活动
Web 标准与前端开发

WebGLRenderingContext: getError() method

· 52CE 我爱测

The **`WebGLRenderingContext.getError()`** method of the WebGL API returns error information.

WebGL

The WebGLRenderingContext.getError() method of the WebGL API returns error information.

Syntax

getError()

Parameters

None.

Return value

<table class="no-markdown"> <thead> <tr> <th scope="col">Constant</th> <th scope="col">Description</th> </tr> </thead> <tbody> <tr> <td><code>gl.NO_ERROR</code></td> <td>No error has been recorded. The value of this constant is 0.</td> </tr> <tr> <td><code>gl.INVALID_ENUM</code></td> <td> An unacceptable value has been specified for an enumerated argument. The command is ignored and the error flag is set. </td> </tr> <tr> <td><code>gl.INVALID_VALUE</code></td> <td> A numeric argument is out of range. The command is ignored and the error flag is set. </td> </tr> <tr> <td><code>gl.INVALID_OPERATION</code></td> <td> The specified command is not allowed for the current state. The command is ignored and the error flag is set. </td> </tr> <tr> <td><code>gl.INVALID_FRAMEBUFFER_OPERATION</code></td> <td> The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it. </td> </tr> <tr> <td><code>gl.OUT_OF_MEMORY</code></td> <td>Not enough memory is left to execute the command.</td> </tr> <tr> <td><code>gl.CONTEXT_LOST_WEBGL</code></td> <td> If the WebGL context is lost, this error is returned on the first call to <code>getError</code>. Afterwards and until the context has been restored, it returns <code>gl.NO_ERROR</code>. </td> </tr> </tbody> </table>

Examples

gl.getError(); // gl.NO_ERROR (0)

gl.enable(gl.FOOBAR);
gl.getError(); // gl.INVALID_ENUM;

Specifications

Browser compatibility

See also

  • WebGLRenderingContext
  • WebGLContextEvent

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。