window.WebGLRenderingContext
和 和有什么不一样canvas.getContext('experimental-webgl')
?
我已经搜索了很多,但我找不到答案。
提前致谢,
window.WebGLRenderingContext
和 和有什么不一样canvas.getContext('experimental-webgl')
?
我已经搜索了很多,但我找不到答案。
提前致谢,
他们说什么:-)
instanceof
还有一件事,你可以使用它
> c = document.createElement("canvas");
<canvas>
> gl = c.getContext("experimental-webgl")
WebGLRenderingContext
> gl instanceof WebGLRenderingContext
true
canvas.getContext
将返回该特定画布的绘图上下文(请参阅规范 §2:上下文创建)。它很可能继承自全局和静态window.WebGLRenderingContext
对象,该对象公开了WebGLRenderingContext
接口(规范 §5.14)。浏览器不需要向 DOM 脚本 API 公开这些本机接口,但它们通常会这样做。
WebGLRenderingContext 是本机实现(或被允许),并不意味着由最终用户直接调用以完成工作。
至少,不像现在那样。
真的,您可以使用它来查看是否支持 WebGL:
if (!!window.WebGLRenderingContext) {
/* webGL is 100% guaranteed to be supported in this browser,
if browser follows standards */
}
或者
if (!window.WebGLRenderingContext) { /* software fallback */ }
但是不能直接使用。