UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.2 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{BufferObject as e}from"./BufferObject.js";import{TextureWrapMode as r,PixelType as t,SizedPixelFormat as o,TextureSamplingMode as n,Usage as i,DataType as s,PrimitiveType as a,ErrorConstant as p}from"./enums.js";import{FramebufferObject as c}from"./FramebufferObject.js";import{makePipelineState as m,destinationTimesOneMinusSourceAlpha as f}from"./renderState.js";import{TextureDescriptor as l}from"./TextureDescriptor.js";import{VertexArrayObject as u}from"./VertexArrayObject.js";import{VertexElementDescriptor as b}from"./VertexElementDescriptor.js";import{WebGLDriverTestModule as d}from"./WebGLDriverTestModule.js";class g extends d{constructor(e){if(super(),this._rctx=e,!e.gl)return;if(!(e.capabilities.colorBufferFloat?.textureFloat&&e.capabilities.colorBufferFloat?.floatBlend))return;const r="\n precision highp float;\n attribute vec2 a_pos;\n\n void main() {\n gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);\n }\n ",t="\n precision highp float;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 0.5);\n }\n ";this._program=e.programCache.acquire(r,t,new Map([["a_pos",0]]))}_test(d){const g=this._rctx,_=new l(1);_.wrapMode=r.CLAMP_TO_EDGE,_.dataType=t.FLOAT,_.internalFormat=o.RGBA32F,_.samplingMode=n.NEAREST;const w=new c(g,_),A=e.createVertex(g,i.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),T=new u(g,new Map([["a_pos",0]]),new Map([["geometry",[new b("a_pos",2,s.UNSIGNED_SHORT,0,4)]]]),new Map([["geometry",A]]));g.gl.getError(),g.useProgram(d);const j=g.getBoundFramebufferObject(),{x,y:E,width:h,height:F}=g.getViewport();g.bindFramebuffer(w),g.setViewport(0,0,1,1),g.bindVAO(T),g.drawArrays(a.TRIANGLE_STRIP,0,4);const O=m({blending:f});g.setPipelineState(O),g.drawArrays(a.TRIANGLE_STRIP,0,4);const y=g.gl.getError();return g.setViewport(x,E,h,F),g.bindFramebuffer(j),T.dispose(),w.dispose(),y!==p.INVALID_OPERATION||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}}export{g as FloatBufferBlend};