-
Notifications
You must be signed in to change notification settings - Fork 1
WebGLDetector
WebGLDetector exists into the WebModule namespace. see: publish to global
var wgl = WebGLDetector;
wgl.detect();
wgl.DETECTED // -> true
wgl.WEBGL_CONTEXT // -> "wegbl"
wgl.WEBGL_VERSION // -> "WebGL 1.0 (OpenGL ES 2.0 Apple A9 GPU - 77.14)"
wgl.WEBGL_VENDOR // -> "Apple Inc."
wgl.WEBGL_RENDERER // -> "Apple A9 GPU"
wgl.WEBGL_SL_VERSION // -> "WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.00)"
wgl.MAX_TEXTURE_SIZE // -> 4096
properties | value | |
---|---|---|
DETECTED | true | Boolean value |
WEBGL_CONTEXT | "webgl" | Enable WebGL function |
WEBGL_VERSION | "WebGL 1.0 (...)" | WebGL Version String |
WEBGL_VENDOR | "Apple Inc." | Vendor String |
WEBGL_RENDERER | "Apple A9 GPU" | Renderer String |
WEBGL_SL_VERSION | "WebGL GLSL ES 1.0..." | GL SL Version String |
MAX_TEXTURE_SIZE | 4096 | Max texture size |
WebGLDetector.detect():void は WebGL 情報の判別を行い、DETECTED, WEBGL_CONTEXT, WEBGL_VERSION, WEBGL_VENDOR, WEBGL_RENDERER, WEBGL_SL_VERSION, MAX_TEXTURE_SIZE を設定します。
WebGLDetector.DETECTED が既に true の場合は再取得は行いません。
判別には、iPhone 6 なら 300〜400ms, iPhone 5 なら 500〜600ms ほど時間がかかります。
判別済みで true になります。
document.createElement("canvas").getContext(...) に指定可能な文字列が格納されています。
values | |
---|---|
"webgl2" | enable WebGL2 and WebGL |
"experimental-webgl2" | enable WebGL2 and WebGL |
"webgl" | enable WebGL |
"experimental-webgl" | enable WebGL |
"" | disable WebGL |
if (WebGLDetector.WEBGL_CONTEXT) {
var canvas = document.createElement("canvas");
var gl = canvas.getContext(WebGLDetector.WEBGL_CONTEXT);
...
}
gl.getParameter(gl.VERSION)
の値です。
WebGLDetector.WEBGL_VERSION // -> "WebGL 1.0 (OpenGL ES 2.0 Chromium)"
gl.getParameter(gl.VENDOR)
または
gl.getParameter(gl.getExtension("WEBGL_debug_renderer_info").UNMASKED_VENDOR_WEBGL)
の値です。
WebGLDetector.WEBGL_VENDOR // -> "Apple Inc."
gl.getParameter(gl.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)
の値です。
WebGLDetector.WEBGL_RENDERER // -> "Apple A9 GPU"
gl.getParameter(gl.SHADING_LANGUAGE_VERSION)
の値です。
WebGLDetector.WEBGL_SL_VERSION // -> "WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.00)"
gl.getParameter(gl.MAX_TEXTURE_SIZE)
の値です。値の範囲は 1024 〜 16384 です。
WebGLDetector.MAX_TEXTURE_SIZE // -> 16384