@@ -124,6 +124,27 @@ class UtilsCore {
124
124
return webGlObj && typeof webGlObj . getExtension === 'function' ;
125
125
}
126
126
127
+ /**
128
+ *
129
+ * @name isWebGl2
130
+ * @function
131
+ * @static
132
+ * @memberOf UtilsCore
133
+ *
134
+ * @desc Return TRUE, on a valid webGl2Context object
135
+ *
136
+ * Note: This does just a VERY simply sanity check. And may give false positives.
137
+ *
138
+ * @param {webGlContext } webGl2Obj - Object to validate
139
+ *
140
+ * @returns {Boolean } TRUE if the object is a webGl2Context object
141
+ *
142
+ */
143
+ static isWebGl2 ( webGl2Obj ) {
144
+ return webGl2Obj && typeof WebGL2RenderingContext !== 'undefined' &&
145
+ webGl2Obj instanceof WebGL2RenderingContext ;
146
+ }
147
+
127
148
/**
128
149
* @name isWebGlSupported
129
150
* @function
@@ -139,6 +160,21 @@ class UtilsCore {
139
160
return _isWebGlSupported ;
140
161
}
141
162
163
+ /**
164
+ * @name isWebGlSupported2
165
+ * @function
166
+ * @static
167
+ * @memberOf UtilsCore
168
+ *
169
+ * @desc Return TRUE, if browser supports webgl2
170
+ *
171
+ * @returns {Boolean } TRUE if browser supports webgl2
172
+ *
173
+ */
174
+ static isWebGl2Supported ( ) {
175
+ return _isWebGl2Supported ;
176
+ }
177
+
142
178
static isWebGlDrawBuffersSupported ( ) {
143
179
return _isWebGlDrawBuffersSupported ;
144
180
}
@@ -253,7 +289,9 @@ class UtilsCore {
253
289
254
290
const _isCanvasSupported = typeof document !== 'undefined' ? UtilsCore . isCanvas ( document . createElement ( 'canvas' ) ) : false ;
255
291
const _testingWebGl = UtilsCore . initWebGl ( UtilsCore . initCanvas ( ) ) ;
292
+ const _testingWebGl2 = UtilsCore . initWebGl2 ( UtilsCore . initCanvas ( ) ) ;
256
293
const _isWebGlSupported = UtilsCore . isWebGl ( _testingWebGl ) ;
294
+ const _isWebGl2Supported = UtilsCore . isWebGl2 ( _testingWebGl2 ) ;
257
295
const _isWebGlDrawBuffersSupported = _isWebGlSupported && Boolean ( _testingWebGl . getExtension ( 'WEBGL_draw_buffers' ) ) ;
258
296
259
297
if ( _isWebGlSupported ) {
0 commit comments