@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.43 kB
JavaScript
import{blendingAlpha as e}from"../3d/webgl-engine/lib/OrderIndependentTransparency.js";import{w as t}from"../../chunks/webgl-debug.js";import{BufferObject as r}from"./BufferObject.js";import{ContextType as o}from"./context-util.js";import{TargetType as i,DepthStencilTargetType as a,TextureType as n,TextureWrapMode as s,PixelFormat as p,PixelType as l,SizedPixelFormat as c,TextureSamplingMode as m,Usage as f,DataType as u,PrimitiveType as d}from"./enums.js";import{FramebufferObject as b}from"./FramebufferObject.js";import{makePipelineState as g}from"./renderState.js";import{VertexArrayObject as _}from"./VertexArrayObject.js";import{VertexElementDescriptor as T}from"./VertexElementDescriptor.js";import{WebGLDriverTestModule as w}from"./WebGLDriverTestModule.js";class x extends w{constructor(e){if(super(),this._rctx=e,!e.gl)return;if(e.type===o.WEBGL1)return void(this._result=!(!e.capabilities.textureFloat?.textureFloat||!e.capabilities.colorBufferFloat?.textureFloat));if(!(e.capabilities.textureFloat?.textureFloat&&e.capabilities.colorBufferFloat?.textureFloat&&e.capabilities.colorBufferFloat?.floatBlend))return;const t="\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 ",r="\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(t,r,new Map([["a_pos",0]]))}_test(o){const w=this._rctx,x=new b(w,{colorTarget:i.TEXTURE,depthStencilTarget:a.NONE},{target:n.TEXTURE_2D,wrapMode:s.CLAMP_TO_EDGE,pixelFormat:p.RGBA,dataType:l.FLOAT,internalFormat:c.RGBA32F,samplingMode:m.NEAREST,width:1,height:1}),F=r.createVertex(w,f.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),h=new _(w,new Map([["a_pos",0]]),{geometry:[new T("a_pos",2,u.UNSIGNED_SHORT,0,4)]},{geometry:F});w.useProgram(o);const E=w.getBoundFramebufferObject(),{x:j,y:A,width:y,height:O}=w.getViewport();w.bindFramebuffer(x),w.setViewport(0,0,1,1),w.bindVAO(h),w.drawArrays(d.TRIANGLE_STRIP,0,4);const R=g({blending:e});w.setPipelineState(R),w.drawArrays(d.TRIANGLE_STRIP,0,4),t.init(w);const B=w.gl.getError();return w.setViewport(j,A,y,O),w.bindFramebuffer(E),h.dispose(!1),F.dispose(),x.dispose(),1282!==B||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}}export{x as FloatBufferBlend};