@luma.gl/webgl 9.0.0-beta.1 → 9.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/webgl-device.d.ts +10 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +16 -1
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/dist.dev.js +73 -115
- package/dist/index.cjs +69 -153
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist.min.js +38 -38
- package/package.json +5 -5
- package/src/adapter/webgl-device.ts +21 -1
- package/src/index.ts +9 -35
|
@@ -83,7 +83,7 @@ export declare class WebGLDevice extends Device {
|
|
|
83
83
|
sourceType?: number;
|
|
84
84
|
}): Uint8Array | Uint16Array | Float32Array;
|
|
85
85
|
/** @deprecated - should use command encoder */
|
|
86
|
-
|
|
86
|
+
readPixelsToBufferWebGL(source: Framebuffer | Texture, options?: {
|
|
87
87
|
sourceX?: number;
|
|
88
88
|
sourceY?: number;
|
|
89
89
|
sourceFormat?: number;
|
|
@@ -93,6 +93,15 @@ export declare class WebGLDevice extends Device {
|
|
|
93
93
|
sourceHeight?: number;
|
|
94
94
|
sourceType?: number;
|
|
95
95
|
}): Buffer;
|
|
96
|
+
setParametersWebGL(parameters: any): void;
|
|
97
|
+
getParametersWebGL(parameters: any): any;
|
|
98
|
+
withParametersWebGL(parameters: any, func: any): any;
|
|
99
|
+
clearWebGL(options?: {
|
|
100
|
+
framebuffer?: Framebuffer;
|
|
101
|
+
color?: any;
|
|
102
|
+
depth?: any;
|
|
103
|
+
stencil?: any;
|
|
104
|
+
}): void;
|
|
96
105
|
/** WebGL1 typed context. Can always be used. */
|
|
97
106
|
readonly gl: WebGLRenderingContext;
|
|
98
107
|
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,OAAO,EACP,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,OAAO,EACP,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAgBtE,OAAO,EAAkC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAU1D,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAEhB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EAEpB,eAAe,EACf,WAAW,EACX,gBAAgB,EAEhB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,gBAAgB,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AAO,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,iEAAiE;IACjE,QAAQ,CAAC,eAAe;;;;MAA0D;IAElF,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IAC/C,WAAW,EAAE,OAAO,CAAS;IAE7B,8CAA8C;IAC9C,OAAO,MAAC;IAER,OAAO,CAAC,YAAY,CAAC,CAAc;IAEnC,mCAAmC;IACnC,IAAI,WAAW,IAAI,WAAW,CAG7B;IAED;;;OAGG;IACM,UAAU,IAAI,OAAO;IAe9B,8DAA8D;IAC9D,SAAS,IAAI,IAAI;IAIjB,8CAA8C;IAC9C,QAAQ,IAAI,IAAI;IAIhB;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMlE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,qBAAqB,GAAG,MAAM;IAc5D,sBAAsB;IACtB,UAAU,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IAElC;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI;CAsBnE"}
|
|
@@ -22,6 +22,9 @@ import { WEBGLCommandEncoder } from "./resources/webgl-command-encoder.js";
|
|
|
22
22
|
import { WEBGLVertexArray } from "./resources/webgl-vertex-array.js";
|
|
23
23
|
import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js";
|
|
24
24
|
import { readPixelsToArray, readPixelsToBuffer } from "../classic/copy-and-blit.js";
|
|
25
|
+
import { setGLParameters, getGLParameters } from "../context/parameters/unified-parameter-api.js";
|
|
26
|
+
import { withGLParameters } from "../context/state-tracker/with-parameters.js";
|
|
27
|
+
import { clear } from "../classic/clear.js";
|
|
25
28
|
const LOG_LEVEL = 1;
|
|
26
29
|
export class WebGLDevice extends Device {
|
|
27
30
|
static isSupported() {
|
|
@@ -264,9 +267,21 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
264
267
|
readPixelsToArrayWebGL(source, options) {
|
|
265
268
|
return readPixelsToArray(source, options);
|
|
266
269
|
}
|
|
267
|
-
|
|
270
|
+
readPixelsToBufferWebGL(source, options) {
|
|
268
271
|
return readPixelsToBuffer(source, options);
|
|
269
272
|
}
|
|
273
|
+
setParametersWebGL(parameters) {
|
|
274
|
+
setGLParameters(this, parameters);
|
|
275
|
+
}
|
|
276
|
+
getParametersWebGL(parameters) {
|
|
277
|
+
return getGLParameters(this, parameters);
|
|
278
|
+
}
|
|
279
|
+
withParametersWebGL(parameters, func) {
|
|
280
|
+
withGLParameters(this, parameters, func);
|
|
281
|
+
}
|
|
282
|
+
clearWebGL(options) {
|
|
283
|
+
clear(this, options);
|
|
284
|
+
}
|
|
270
285
|
get webglLimits() {
|
|
271
286
|
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
272
287
|
return this._webglLimits;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.js","names":["Device","CanvasContext","log","uid","assert","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","WEBGLBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLVertexArray","WEBGLTransformFeedback","readPixelsToArray","readPixelsToBuffer","LOG_LEVEL","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","arguments","length","undefined","groupCollapsed","canvas","pageLoaded","get","debug","spector","probe","message","info","type","vendor","renderer","canvasContext","id","table","groupEnd","constructor","_props$gl","_props$gl2","handle","lost","_resolveContextLost","renderPass","gl2","isWebGL1","isWebGL2","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_extensions","_polyfilled","_webglLimits","_constants","Promise","resolve","onContextLost","event","_this$_resolveContext","call","reason","resize","_version","enable","copyState","_len","args","Array","_key","webgl2","throwOnError","level","Math","max","warn","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","createVertexArray","beginRenderPass","createComputePipeline","beginComputePass","createTransformFeedback","getDefaultRenderPass","framebuffer","getCurrentFramebuffer","createCommandEncoder","submit","_this$renderPass","end","readPixelsToArrayWebGL","source","options","readPixelsToBufferWebGL2","webglLimits","loseDevice","_this$_resolveContext2","deviceLossTriggered","loseContext","pushState","popState","setSpectorMetadata","__SPECTOR_Metadata","getGLKey","value","number","Number","key","String","setConstantAttribute","location","constant","maxVertexAttributes","fill","currentConstant","compareConstantArrayValues","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","WebGL2RenderingContext","Boolean","isFinite","array","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","v1","v2","i"],"sources":["../../src/adapter/webgl-device.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat,\n VertexArray,\n VertexArrayProps,\n Framebuffer,\n Buffer,\n Texture,\n TypedArray\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {\n popContextState,\n pushContextState,\n trackContextState\n} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n // Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n // RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n // RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps,\n // CommandEncoder,\n CommandEncoderProps,\n TransformFeedbackProps\n} from '@luma.gl/core';\n\nimport {WEBGLBuffer} from './resources/webgl-buffer';\nimport {WEBGLShader} from './resources/webgl-shader';\nimport {WEBGLSampler} from './resources/webgl-sampler';\nimport {WEBGLTexture} from './resources/webgl-texture';\nimport {WEBGLFramebuffer} from './resources/webgl-framebuffer';\nimport {WEBGLRenderPass} from './resources/webgl-render-pass';\nimport {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';\nimport {WEBGLCommandEncoder} from './resources/webgl-command-encoder';\nimport {WEBGLVertexArray} from './resources/webgl-vertex-array';\nimport {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';\n\nimport {readPixelsToArray, readPixelsToBuffer} from '../classic/copy-and-blit';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (log.get('debug') || props.debug) {\n await loadWebGLDeveloperTools();\n }\n\n // @ts-expect-error spector not on props\n const {spector} = props;\n if (log.get('spector') || spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n const device = new WebGLDevice(props);\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${device.info.type}${device.debug ? ' debug' : ''} context: \\\n${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n log.table(LOG_LEVEL, device.info)();\n\n log.groupEnd(LOG_LEVEL)();\n\n return device;\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n const canvas = props.canvas || props.gl?.canvas;\n this.canvasContext = new WebGLCanvasContext(this, {...props, canvas});\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser()\n ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})\n : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n this.canvasContext.resize();\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {\n const newProps = this._getBufferProps(props);\n return new WEBGLBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n override createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('ComputePass not supported in WebGL');\n }\n\n createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {\n return new WEBGLTransformFeedback(this, props);\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n override createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder {\n return new WEBGLCommandEncoder(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.end();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // TEMPORARY HACKS - will be removed in v9.1\n // \n\n /** @deprecated - should use command encoder */\n override readPixelsToArrayWebGL(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Uint8Array | Uint16Array | Float32Array {\n return readPixelsToArray(source, options);\n }\n\n /** @deprecated - should use command encoder */\n override readPixelsToBufferWebGL2(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Buffer {\n return readPixelsToBuffer(source, options);\n }\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** State used by luma.gl classes - TODO - not used? */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n /**\n * Triggers device (or WebGL context) loss.\n * @note primarily intended for testing how application reacts to device loss\n */\n override loseDevice(): boolean {\n let deviceLossTriggered = false;\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n deviceLossTriggered = true;\n ext.loseContext();\n // ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly\n }\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n return deviceLossTriggered;\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\n }\n\n /**\n * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension\n * luma.gl ids and props can be inspected\n */\n setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant\n * Be aware that there are some duplicates especially for constants that are 0,\n * so this isn't guaranteed to return the right key in all cases.\n */\n getGLKey(value: unknown, gl?: WebGLRenderingContext): string {\n // @ts-ignore expect-error depends on settings\n gl = gl || this.gl2 || this.gl;\n const number = Number(value);\n for (const key in gl) {\n // @ts-ignore expect-error depends on settings\n if (gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return String(value);\n }\n\n /** Store constants */\n _constants: (TypedArray | null)[];\n\n /**\n * Set a constant value for a location. Disabled attributes at that location will read from this value\n * @note WebGL constants are stored globally on the WebGL context, not the VertexArray\n * so they need to be updated before every render\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstantAttribute(location: number, constant: TypedArray): void {\n this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();\n }\n this._constants[location] = constant;\n\n switch (constant.constructor) {\n case Float32Array:\n setConstantFloatArray(this, location, constant as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this, location, constant as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this, location, constant as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n/** Set constant float array attribute */\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\n/** Set constant signed int array attribute */\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** Set constant unsigned int array attribute */\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/**\n * Compares contents of two typed arrays\n * @todo max length?\n */\nfunction compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":"AAiBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AACrE,SAAQC,SAAS,QAAO,eAAe;AAAC,SAChCC,eAAe;AAAA,SAErBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB;AAAA,SAEXC,oBAAoB;AAAA,SAE1BC,qBAAqB,EACrBC,sBAAsB;AAAA,SAEhBC,aAAa;AAAA,SACbC,iBAAiB;AAAA,SACjBC,eAAe,EAAEC,cAAc;AAAA,SAC/BC,kBAAkB;AAAA,SAClBC,aAAa,EAAEC,mBAAmB;AAAA,SAClCC,uBAAuB,EAAEC,gBAAgB;AAAA,SAE/CC,wBAAwB,EACxBC,yBAAyB,EACzBC,yBAAyB;AAAA,SA0BnBC,WAAW;AAAA,SACXC,WAAW;AAAA,SACXC,YAAY;AAAA,SACZC,YAAY;AAAA,SACZC,gBAAgB;AAAA,SAChBC,eAAe;AAAA,SACfC,mBAAmB;AAAA,SACnBC,mBAAmB;AAAA,SACnBC,gBAAgB;AAAA,SAChBC,sBAAsB;AAAA,SAEtBC,iBAAiB,EAAEC,kBAAkB;AAE7C,MAAMC,SAAS,GAAG,CAAC;AAGnB,OAAO,MAAMC,WAAW,SAAStC,MAAM,CAAC;EAOtC,OAAOuC,WAAWA,CAAA,EAAY;IAC5B,OAAO,OAAOC,qBAAqB,KAAK,WAAW,IAAI5B,sBAAsB,CAAC,CAAC;EACjF;EAOA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C5H,MAAmB,EAAEmH,QAAgB,EAAEe,KAAiB,EAAQ;EAAA,IAAAK,UAAA;EAC3FvI,MAAM,CAACwE,YAAY,CAAC,CAAC;EACrB,CAAA+D,UAAA,GAAAvI,MAAM,CAAC+B,GAAG,cAAAwG,UAAA,uBAAVA,UAAA,CAAYC,gBAAgB,CAACrB,QAAQ,EAAEe,KAAK,CAAC;AAiB/C;AAGA,SAASJ,oBAAoBA,CAAC9H,MAAmB,EAAEmH,QAAgB,EAAEe,KAAkB,EAAE;EAAA,IAAAO,WAAA;EACvFzI,MAAM,CAACwE,YAAY,CAAC,CAAC;EACrB,CAAAiE,WAAA,GAAAzI,MAAM,CAAC+B,GAAG,cAAA0G,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAACvB,QAAQ,EAAEe,KAAK,CAAC;AAkBhD;AAMA,SAASV,0BAA0BA,CAACmB,EAAc,EAAEC,EAAc,EAAW;EAC3E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAACrI,MAAM,KAAKsI,EAAE,CAACtI,MAAM,IAAIqI,EAAE,CAACnH,WAAW,KAAKoH,EAAE,CAACpH,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIqH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAACrI,MAAM,EAAE,EAAEuI,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"webgl-device.js","names":["Device","CanvasContext","log","uid","assert","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","WEBGLBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLVertexArray","WEBGLTransformFeedback","readPixelsToArray","readPixelsToBuffer","setGLParameters","getGLParameters","withGLParameters","clear","LOG_LEVEL","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","arguments","length","undefined","groupCollapsed","canvas","pageLoaded","get","debug","spector","probe","message","info","type","vendor","renderer","canvasContext","id","table","groupEnd","constructor","_props$gl","_props$gl2","handle","lost","_resolveContextLost","renderPass","gl2","isWebGL1","isWebGL2","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_extensions","_polyfilled","_webglLimits","_constants","Promise","resolve","onContextLost","event","_this$_resolveContext","call","reason","resize","_version","enable","copyState","_len","args","Array","_key","webgl2","throwOnError","level","Math","max","warn","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","createVertexArray","beginRenderPass","createComputePipeline","beginComputePass","createTransformFeedback","getDefaultRenderPass","framebuffer","getCurrentFramebuffer","createCommandEncoder","submit","_this$renderPass","end","readPixelsToArrayWebGL","source","options","readPixelsToBufferWebGL","setParametersWebGL","parameters","getParametersWebGL","withParametersWebGL","func","clearWebGL","webglLimits","loseDevice","_this$_resolveContext2","deviceLossTriggered","loseContext","pushState","popState","setSpectorMetadata","__SPECTOR_Metadata","getGLKey","value","number","Number","key","String","setConstantAttribute","location","constant","maxVertexAttributes","fill","currentConstant","compareConstantArrayValues","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","WebGL2RenderingContext","Boolean","isFinite","array","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","v1","v2","i"],"sources":["../../src/adapter/webgl-device.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat,\n VertexArray,\n VertexArrayProps,\n Framebuffer,\n Buffer,\n Texture,\n TypedArray\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {\n popContextState,\n pushContextState,\n trackContextState\n} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\n\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n // Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n // RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n // RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps,\n // CommandEncoder,\n CommandEncoderProps,\n TransformFeedbackProps\n} from '@luma.gl/core';\n\nimport {WEBGLBuffer} from './resources/webgl-buffer';\nimport {WEBGLShader} from './resources/webgl-shader';\nimport {WEBGLSampler} from './resources/webgl-sampler';\nimport {WEBGLTexture} from './resources/webgl-texture';\nimport {WEBGLFramebuffer} from './resources/webgl-framebuffer';\nimport {WEBGLRenderPass} from './resources/webgl-render-pass';\nimport {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';\nimport {WEBGLCommandEncoder} from './resources/webgl-command-encoder';\nimport {WEBGLVertexArray} from './resources/webgl-vertex-array';\nimport {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';\n\nimport {readPixelsToArray, readPixelsToBuffer} from '../classic/copy-and-blit';\nimport {setGLParameters, getGLParameters} from '../context/parameters/unified-parameter-api';\nimport {withGLParameters} from '../context/state-tracker/with-parameters';\nimport {clear} from '../classic/clear';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (log.get('debug') || props.debug) {\n await loadWebGLDeveloperTools();\n }\n\n // @ts-expect-error spector not on props\n const {spector} = props;\n if (log.get('spector') || spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n const device = new WebGLDevice(props);\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${device.info.type}${device.debug ? ' debug' : ''} context: \\\n${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n log.table(LOG_LEVEL, device.info)();\n\n log.groupEnd(LOG_LEVEL)();\n\n return device;\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n const canvas = props.canvas || props.gl?.canvas;\n this.canvasContext = new WebGLCanvasContext(this, {...props, canvas});\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser()\n ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})\n : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n this.canvasContext.resize();\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {\n const newProps = this._getBufferProps(props);\n return new WEBGLBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n override createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('ComputePass not supported in WebGL');\n }\n\n createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {\n return new WEBGLTransformFeedback(this, props);\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n override createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder {\n return new WEBGLCommandEncoder(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.end();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // TEMPORARY HACKS - will be removed in v9.1\n // \n\n /** @deprecated - should use command encoder */\n override readPixelsToArrayWebGL(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Uint8Array | Uint16Array | Float32Array {\n return readPixelsToArray(source, options);\n }\n\n /** @deprecated - should use command encoder */\n override readPixelsToBufferWebGL(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Buffer {\n return readPixelsToBuffer(source, options);\n }\n\n override setParametersWebGL(parameters: any): void {\n setGLParameters(this, parameters);\n }\n\n override getParametersWebGL(parameters: any): any {\n return getGLParameters(this, parameters);\n }\n\n override withParametersWebGL(parameters: any, func: any): any {\n withGLParameters(this, parameters, func);\n }\n\n override clearWebGL(options?: {framebuffer?: Framebuffer; color?: any; depth?: any; stencil?: any}): void {\n clear(this, options);\n }\n \n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** State used by luma.gl classes - TODO - not used? */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n /**\n * Triggers device (or WebGL context) loss.\n * @note primarily intended for testing how application reacts to device loss\n */\n override loseDevice(): boolean {\n let deviceLossTriggered = false;\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n deviceLossTriggered = true;\n ext.loseContext();\n // ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly\n }\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n return deviceLossTriggered;\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\n }\n\n /**\n * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension\n * luma.gl ids and props can be inspected\n */\n setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant\n * Be aware that there are some duplicates especially for constants that are 0,\n * so this isn't guaranteed to return the right key in all cases.\n */\n getGLKey(value: unknown, gl?: WebGLRenderingContext): string {\n // @ts-ignore expect-error depends on settings\n gl = gl || this.gl2 || this.gl;\n const number = Number(value);\n for (const key in gl) {\n // @ts-ignore expect-error depends on settings\n if (gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return String(value);\n }\n\n /** Store constants */\n _constants: (TypedArray | null)[];\n\n /**\n * Set a constant value for a location. Disabled attributes at that location will read from this value\n * @note WebGL constants are stored globally on the WebGL context, not the VertexArray\n * so they need to be updated before every render\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstantAttribute(location: number, constant: TypedArray): void {\n this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();\n }\n this._constants[location] = constant;\n\n switch (constant.constructor) {\n case Float32Array:\n setConstantFloatArray(this, location, constant as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this, location, constant as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this, location, constant as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n/** Set constant float array attribute */\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\n/** Set constant signed int array attribute */\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** Set constant unsigned int array attribute */\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/**\n * Compares contents of two typed arrays\n * @todo max length?\n */\nfunction compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":"AAiBA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AACrE,SAAQC,SAAS,QAAO,eAAe;AAAC,SAChCC,eAAe;AAAA,SAErBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB;AAAA,SAEXC,oBAAoB;AAAA,SAE1BC,qBAAqB,EACrBC,sBAAsB;AAAA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B,CAAAqE,UAAA,GAAA7I,MAAM,CAAC+B,GAAG,cAAA8G,UAAA,uBAAVA,UAAA,CAAYC,gBAAgB,CAACrB,QAAQ,EAAEe,KAAK,CAAC;AAiB/C;AAGA,SAASJ,oBAAoBA,CAACpI,MAAmB,EAAEyH,QAAgB,EAAEe,KAAkB,EAAE;EAAA,IAAAO,WAAA;EACvF/I,MAAM,CAACwE,YAAY,CAAC,CAAC;EACrB,CAAAuE,WAAA,GAAA/I,MAAM,CAAC+B,GAAG,cAAAgH,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAACvB,QAAQ,EAAEe,KAAK,CAAC;AAkBhD;AAMA,SAASV,0BAA0BA,CAACmB,EAAc,EAAEC,EAAc,EAAW;EAC3E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAC3I,MAAM,KAAK4I,EAAE,CAAC5I,MAAM,IAAI2I,EAAE,CAACzH,WAAW,KAAK0H,EAAE,CAAC1H,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAI2H,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAC3I,MAAM,EAAE,EAAE6I,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -51,9 +51,7 @@ var __exports__ = (() => {
|
|
|
51
51
|
_checkFloat32ColorAttachment: () => _checkFloat32ColorAttachment,
|
|
52
52
|
assertWebGL2Context: () => assertWebGL2Context,
|
|
53
53
|
assertWebGLContext: () => assertWebGLContext,
|
|
54
|
-
clear: () => clear,
|
|
55
54
|
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
56
|
-
copyToTexture: () => copyToTexture,
|
|
57
55
|
getGLParameters: () => getGLParameters,
|
|
58
56
|
getShaderLayout: () => getShaderLayout,
|
|
59
57
|
getWebGL2Context: () => getWebGL2Context,
|
|
@@ -62,8 +60,6 @@ var __exports__ = (() => {
|
|
|
62
60
|
polyfillContext: () => polyfillContext,
|
|
63
61
|
popContextState: () => popContextState,
|
|
64
62
|
pushContextState: () => pushContextState,
|
|
65
|
-
readPixelsToArray: () => readPixelsToArray,
|
|
66
|
-
readPixelsToBuffer: () => readPixelsToBuffer,
|
|
67
63
|
registerHeadlessGL: () => registerHeadlessGL,
|
|
68
64
|
resetGLParameters: () => resetGLParameters,
|
|
69
65
|
setDeviceParameters: () => setDeviceParameters,
|
|
@@ -1127,7 +1123,19 @@ var __exports__ = (() => {
|
|
|
1127
1123
|
readPixelsToArrayWebGL(source, options) {
|
|
1128
1124
|
throw new Error("not implemented");
|
|
1129
1125
|
}
|
|
1130
|
-
|
|
1126
|
+
readPixelsToBufferWebGL(source, options) {
|
|
1127
|
+
throw new Error("not implemented");
|
|
1128
|
+
}
|
|
1129
|
+
setParametersWebGL(parameters) {
|
|
1130
|
+
throw new Error("not implemented");
|
|
1131
|
+
}
|
|
1132
|
+
getParametersWebGL(parameters) {
|
|
1133
|
+
throw new Error("not implemented");
|
|
1134
|
+
}
|
|
1135
|
+
withParametersWebGL(parameters, func) {
|
|
1136
|
+
throw new Error("not implemented");
|
|
1137
|
+
}
|
|
1138
|
+
clearWebGL(options) {
|
|
1131
1139
|
throw new Error("not implemented");
|
|
1132
1140
|
}
|
|
1133
1141
|
_getBufferProps(props) {
|
|
@@ -1505,7 +1513,8 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
1505
1513
|
return numberedLines;
|
|
1506
1514
|
}
|
|
1507
1515
|
function getNumberedLine(line, lineNum, options) {
|
|
1508
|
-
|
|
1516
|
+
const escapedLine = options?.html ? escapeHTML(line) : line;
|
|
1517
|
+
return `${padLeft(String(lineNum), 4)}: ${escapedLine}${options?.html ? "<br/>" : "\n"}`;
|
|
1509
1518
|
}
|
|
1510
1519
|
function padLeft(string, paddedLength) {
|
|
1511
1520
|
let result = "";
|
|
@@ -1514,6 +1523,9 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
1514
1523
|
}
|
|
1515
1524
|
return result + string;
|
|
1516
1525
|
}
|
|
1526
|
+
function escapeHTML(unsafe) {
|
|
1527
|
+
return unsafe.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1528
|
+
}
|
|
1517
1529
|
|
|
1518
1530
|
// ../core/src/lib/compiler-log/get-shader-info.ts
|
|
1519
1531
|
function getShaderInfo(source, defaultName) {
|
|
@@ -8858,72 +8870,6 @@ ${source2}`;
|
|
|
8858
8870
|
}
|
|
8859
8871
|
return webglBufferTarget;
|
|
8860
8872
|
}
|
|
8861
|
-
function copyToTexture(source, target, options) {
|
|
8862
|
-
const {
|
|
8863
|
-
sourceX = 0,
|
|
8864
|
-
sourceY = 0,
|
|
8865
|
-
targetMipmaplevel = 0,
|
|
8866
|
-
targetInternalFormat = 6408
|
|
8867
|
-
} = options || {};
|
|
8868
|
-
let {
|
|
8869
|
-
targetX,
|
|
8870
|
-
targetY,
|
|
8871
|
-
targetZ,
|
|
8872
|
-
width,
|
|
8873
|
-
height
|
|
8874
|
-
} = options || {};
|
|
8875
|
-
const {
|
|
8876
|
-
framebuffer,
|
|
8877
|
-
deleteFramebuffer
|
|
8878
|
-
} = getFramebuffer2(source);
|
|
8879
|
-
assert2(framebuffer);
|
|
8880
|
-
const webglFramebuffer = framebuffer;
|
|
8881
|
-
const {
|
|
8882
|
-
device,
|
|
8883
|
-
handle
|
|
8884
|
-
} = webglFramebuffer;
|
|
8885
|
-
const isSubCopy = typeof targetX !== "undefined" || typeof targetY !== "undefined" || typeof targetZ !== "undefined";
|
|
8886
|
-
targetX = targetX || 0;
|
|
8887
|
-
targetY = targetY || 0;
|
|
8888
|
-
targetZ = targetZ || 0;
|
|
8889
|
-
const prevHandle = device.gl.bindFramebuffer(36160, handle);
|
|
8890
|
-
assert2(target);
|
|
8891
|
-
let texture = null;
|
|
8892
|
-
let textureTarget;
|
|
8893
|
-
if (target instanceof Texture) {
|
|
8894
|
-
texture = target;
|
|
8895
|
-
width = Number.isFinite(width) ? width : texture.width;
|
|
8896
|
-
height = Number.isFinite(height) ? height : texture.height;
|
|
8897
|
-
texture.bind(0);
|
|
8898
|
-
textureTarget = texture.target;
|
|
8899
|
-
} else {
|
|
8900
|
-
textureTarget = target;
|
|
8901
|
-
}
|
|
8902
|
-
if (!isSubCopy) {
|
|
8903
|
-
device.gl.copyTexImage2D(textureTarget, targetMipmaplevel, targetInternalFormat, sourceX, sourceY, width, height, 0);
|
|
8904
|
-
} else {
|
|
8905
|
-
switch (textureTarget) {
|
|
8906
|
-
case 3553:
|
|
8907
|
-
case 34067:
|
|
8908
|
-
device.gl.copyTexSubImage2D(textureTarget, targetMipmaplevel, targetX, targetY, sourceX, sourceY, width, height);
|
|
8909
|
-
break;
|
|
8910
|
-
case 35866:
|
|
8911
|
-
case 32879:
|
|
8912
|
-
device.assertWebGL2();
|
|
8913
|
-
device.gl2.copyTexSubImage3D(textureTarget, targetMipmaplevel, targetX, targetY, targetZ, sourceX, sourceY, width, height);
|
|
8914
|
-
break;
|
|
8915
|
-
default:
|
|
8916
|
-
}
|
|
8917
|
-
}
|
|
8918
|
-
if (texture) {
|
|
8919
|
-
texture.unbind();
|
|
8920
|
-
}
|
|
8921
|
-
device.gl.bindFramebuffer(36160, prevHandle || null);
|
|
8922
|
-
if (deleteFramebuffer) {
|
|
8923
|
-
framebuffer.destroy();
|
|
8924
|
-
}
|
|
8925
|
-
return texture;
|
|
8926
|
-
}
|
|
8927
8873
|
function getFramebuffer2(source) {
|
|
8928
8874
|
if (!(source instanceof Framebuffer)) {
|
|
8929
8875
|
return {
|
|
@@ -8964,6 +8910,48 @@ ${source2}`;
|
|
|
8964
8910
|
return new ArrayType(width * height * components);
|
|
8965
8911
|
}
|
|
8966
8912
|
|
|
8913
|
+
// src/classic/clear.ts
|
|
8914
|
+
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
8915
|
+
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
8916
|
+
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
8917
|
+
var ERR_ARGUMENTS = "clear: bad arguments";
|
|
8918
|
+
function clear(gl, options) {
|
|
8919
|
+
const device = WebGLDevice.attach(gl);
|
|
8920
|
+
const {
|
|
8921
|
+
framebuffer = null,
|
|
8922
|
+
color = null,
|
|
8923
|
+
depth = null,
|
|
8924
|
+
stencil = null
|
|
8925
|
+
} = options || {};
|
|
8926
|
+
const parameters = {};
|
|
8927
|
+
if (framebuffer) {
|
|
8928
|
+
parameters.framebuffer = framebuffer;
|
|
8929
|
+
}
|
|
8930
|
+
let clearFlags = 0;
|
|
8931
|
+
if (color) {
|
|
8932
|
+
clearFlags |= GL_COLOR_BUFFER_BIT2;
|
|
8933
|
+
if (color !== true) {
|
|
8934
|
+
parameters.clearColor = color;
|
|
8935
|
+
}
|
|
8936
|
+
}
|
|
8937
|
+
if (depth) {
|
|
8938
|
+
clearFlags |= GL_DEPTH_BUFFER_BIT2;
|
|
8939
|
+
if (depth !== true) {
|
|
8940
|
+
parameters.clearDepth = depth;
|
|
8941
|
+
}
|
|
8942
|
+
}
|
|
8943
|
+
if (stencil) {
|
|
8944
|
+
clearFlags |= GL_STENCIL_BUFFER_BIT2;
|
|
8945
|
+
if (depth !== true) {
|
|
8946
|
+
parameters.clearStencil = depth;
|
|
8947
|
+
}
|
|
8948
|
+
}
|
|
8949
|
+
assert2(clearFlags !== 0, ERR_ARGUMENTS);
|
|
8950
|
+
withGLParameters(device.gl, parameters, () => {
|
|
8951
|
+
device.gl.clear(clearFlags);
|
|
8952
|
+
});
|
|
8953
|
+
}
|
|
8954
|
+
|
|
8967
8955
|
// src/adapter/webgl-device.ts
|
|
8968
8956
|
var LOG_LEVEL2 = 1;
|
|
8969
8957
|
var _WebGLDevice = class extends Device {
|
|
@@ -9172,9 +9160,21 @@ ${source2}`;
|
|
|
9172
9160
|
readPixelsToArrayWebGL(source, options) {
|
|
9173
9161
|
return readPixelsToArray(source, options);
|
|
9174
9162
|
}
|
|
9175
|
-
|
|
9163
|
+
readPixelsToBufferWebGL(source, options) {
|
|
9176
9164
|
return readPixelsToBuffer(source, options);
|
|
9177
9165
|
}
|
|
9166
|
+
setParametersWebGL(parameters) {
|
|
9167
|
+
setGLParameters(this, parameters);
|
|
9168
|
+
}
|
|
9169
|
+
getParametersWebGL(parameters) {
|
|
9170
|
+
return getGLParameters(this, parameters);
|
|
9171
|
+
}
|
|
9172
|
+
withParametersWebGL(parameters, func) {
|
|
9173
|
+
withGLParameters(this, parameters, func);
|
|
9174
|
+
}
|
|
9175
|
+
clearWebGL(options) {
|
|
9176
|
+
clear(this, options);
|
|
9177
|
+
}
|
|
9178
9178
|
gl2 = null;
|
|
9179
9179
|
debug = false;
|
|
9180
9180
|
_canvasSizeInfo = {
|
|
@@ -9296,48 +9296,6 @@ ${source2}`;
|
|
|
9296
9296
|
}
|
|
9297
9297
|
return true;
|
|
9298
9298
|
}
|
|
9299
|
-
|
|
9300
|
-
// src/classic/clear.ts
|
|
9301
|
-
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
9302
|
-
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
9303
|
-
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
9304
|
-
var ERR_ARGUMENTS = "clear: bad arguments";
|
|
9305
|
-
function clear(gl, options) {
|
|
9306
|
-
const device = WebGLDevice.attach(gl);
|
|
9307
|
-
const {
|
|
9308
|
-
framebuffer = null,
|
|
9309
|
-
color = null,
|
|
9310
|
-
depth = null,
|
|
9311
|
-
stencil = null
|
|
9312
|
-
} = options || {};
|
|
9313
|
-
const parameters = {};
|
|
9314
|
-
if (framebuffer) {
|
|
9315
|
-
parameters.framebuffer = framebuffer;
|
|
9316
|
-
}
|
|
9317
|
-
let clearFlags = 0;
|
|
9318
|
-
if (color) {
|
|
9319
|
-
clearFlags |= GL_COLOR_BUFFER_BIT2;
|
|
9320
|
-
if (color !== true) {
|
|
9321
|
-
parameters.clearColor = color;
|
|
9322
|
-
}
|
|
9323
|
-
}
|
|
9324
|
-
if (depth) {
|
|
9325
|
-
clearFlags |= GL_DEPTH_BUFFER_BIT2;
|
|
9326
|
-
if (depth !== true) {
|
|
9327
|
-
parameters.clearDepth = depth;
|
|
9328
|
-
}
|
|
9329
|
-
}
|
|
9330
|
-
if (stencil) {
|
|
9331
|
-
clearFlags |= GL_STENCIL_BUFFER_BIT2;
|
|
9332
|
-
if (depth !== true) {
|
|
9333
|
-
parameters.clearStencil = depth;
|
|
9334
|
-
}
|
|
9335
|
-
}
|
|
9336
|
-
assert2(clearFlags !== 0, ERR_ARGUMENTS);
|
|
9337
|
-
withGLParameters(device.gl, parameters, () => {
|
|
9338
|
-
device.gl.clear(clearFlags);
|
|
9339
|
-
});
|
|
9340
|
-
}
|
|
9341
9299
|
return __toCommonJS(src_exports);
|
|
9342
9300
|
})();
|
|
9343
9301
|
return __exports__;
|