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