admin管理员组文章数量:1431788
What is the difference between window.WebGLRenderingContext
and canvas.getContext('experimental-webgl')
?
I've searched a lot, but I can't find the answer.
Thanks in advance,
What is the difference between window.WebGLRenderingContext
and canvas.getContext('experimental-webgl')
?
I've searched a lot, but I can't find the answer.
Thanks in advance,
Share Improve this question asked Dec 18, 2012 at 17:47 Hard RainHard Rain 1,4204 gold badges15 silver badges19 bronze badges 2- It might help if you shared what you found in your search. – Aaron Kurtzhals Commented Dec 18, 2012 at 17:49
-
Nothing useful. This is a function, and if
!!window.WebGLRenderingContext
is false, then webgl is not supported. – Hard Rain Commented Dec 18, 2012 at 17:53
3 Answers
Reset to default 3What they said :-)
One more thing, you can use it with instanceof
as in
> c = document.createElement("canvas");
<canvas>
> gl = c.getContext("experimental-webgl")
WebGLRenderingContext
> gl instanceof WebGLRenderingContext
true
canvas.getContext
will return a drawing context for that particular canvas (see spec §2: Context Creation). It will likely inherit from the global and static window.WebGLRenderingContext
object, which exposes the WebGLRenderingContext
interface (spec §5.14). A browser does not need to expose those native interfaces to the DOM scripting API, but they usually do.
WebGLRenderingContext is a native implementation (or is allowed to be), and isn't meant to be called by the end-user, directly, in order to do work.
At least, not as it currently-exists.
Really, you can use it to see if WebGL is supported:
if (!!window.WebGLRenderingContext) {
/* webGL is 100% guaranteed to be supported in this browser,
if browser follows standards */
}
or
if (!window.WebGLRenderingContext) { /* software fallback */ }
But it can not be used directly.
本文标签: javascriptWhat is windowWebGLRenderingContextStack Overflow
版权声明:本文标题:javascript - What is window.WebGLRenderingContext? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745563509a2663619.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论