Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isWebGLSupported()
- {
- const contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true };
- try
- {
- if (!window.WebGLRenderingContext)
- {
- console.log('No window.WebGLRenderingContext');
- return false;
- }
- const canvas = document.createElement('canvas');
- let gl = canvas.getContext('webgl', contextOptions) || canvas.getContext('experimental-webgl', contextOptions);
- if (!gl) {
- console.log('no webgl context');
- }
- if (!gl.getContextAttributes().stencil) {
- console.log('no stencil');
- }
- const success = !!(gl && gl.getContextAttributes().stencil);
- if (gl)
- {
- const loseContext = gl.getExtension('WEBGL_lose_context');
- if (loseContext)
- {
- loseContext.loseContext();
- }
- }
- gl = null;
- return success;
- }
- catch (e)
- {
- console.log('catched error', e);
- return false;
- }
- }
- isWebGLSupported();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement