@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.57 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{loadDebugRendererInfo as e}from"./capabilities/DebugRendererInfo.js";let r;function t(){return r??=l(),r}class o{constructor(){this.available=!1,this.majorPerformanceCaveat=!1,this.maxTextureSize=0,this.supportsVertexShaderSamplers=!1,this.supportsHighPrecisionFragment=!1,this.supportsColorBufferFloat=!1,this.supportsColorBufferFloatBlend=!1,this.supportsColorBufferHalfFloat=!1,this.unmaskedRenderer="unloaded"}}function n(e){if("undefined"==typeof WebGL2RenderingContext)return null;const r=document.createElement("canvas");if(!r)return null;let t=r.getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(null==t&&(t=r.getContext("webgl2"),null!=t&&(e.majorPerformanceCaveat=!0)),null==t)return t;e.available=!0,e.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),e.supportsVertexShaderSamplers=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;const o=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);return o&&(e.supportsHighPrecisionFragment=o.precision>0),t}function l(){const r=new o,t=n(r);return null==t||(r.supportsColorBufferFloat=null!==t.getExtension("EXT_color_buffer_float"),r.supportsColorBufferFloatBlend=null!==t.getExtension("EXT_float_blend"),r.supportsColorBufferHalfFloat=r.supportsColorBufferFloat||null!==t.getExtension("EXT_color_buffer_half_float"),r.unmaskedRenderer=e(t,{debugRendererInfo:!0})?.getUnmaskedRendererWebGL()??"unknown"),r}export{t as getWebGLCapabilities};