@luma.gl/webgl 9.0.0-alpha.10 → 9.0.0-alpha.11

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.
Files changed (45) hide show
  1. package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
  2. package/dist/adapter/webgl-canvas-context.js +1 -3
  3. package/dist/adapter/webgl-canvas-context.js.map +1 -1
  4. package/dist/adapter/webgl-device.d.ts +33 -27
  5. package/dist/adapter/webgl-device.d.ts.map +1 -1
  6. package/dist/adapter/webgl-device.js +32 -24
  7. package/dist/adapter/webgl-device.js.map +1 -1
  8. package/dist/context/context/context-state.d.ts +0 -5
  9. package/dist/context/context/context-state.d.ts.map +1 -1
  10. package/dist/context/context/context-state.js +0 -5
  11. package/dist/context/context/context-state.js.map +1 -1
  12. package/dist/es5/adapter/webgl-canvas-context.js +1 -4
  13. package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
  14. package/dist/es5/adapter/webgl-device.js +34 -24
  15. package/dist/es5/adapter/webgl-device.js.map +1 -1
  16. package/dist/es5/context/context/context-state.js +0 -5
  17. package/dist/es5/context/context/context-state.js.map +1 -1
  18. package/dist/es5/index.js +0 -14
  19. package/dist/es5/index.js.map +1 -1
  20. package/dist/esm/adapter/webgl-canvas-context.js +1 -3
  21. package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
  22. package/dist/esm/adapter/webgl-device.js +32 -24
  23. package/dist/esm/adapter/webgl-device.js.map +1 -1
  24. package/dist/esm/context/context/context-state.js +0 -5
  25. package/dist/esm/context/context/context-state.js.map +1 -1
  26. package/dist/esm/index.js +0 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +0 -1
  31. package/dist/index.js.map +1 -1
  32. package/package.json +4 -4
  33. package/src/adapter/webgl-canvas-context.ts +1 -3
  34. package/src/adapter/webgl-device.ts +60 -48
  35. package/src/context/context/context-state.ts +0 -10
  36. package/src/index.ts +0 -3
  37. package/dist/context/context/device-pixels.d.ts +0 -25
  38. package/dist/context/context/device-pixels.d.ts.map +0 -1
  39. package/dist/context/context/device-pixels.js +0 -103
  40. package/dist/context/context/device-pixels.js.map +0 -1
  41. package/dist/es5/context/context/device-pixels.js +0 -121
  42. package/dist/es5/context/context/device-pixels.js.map +0 -1
  43. package/dist/esm/context/context/device-pixels.js +0 -103
  44. package/dist/esm/context/context/device-pixels.js.map +0 -1
  45. package/src/context/context/device-pixels.ts +0 -158
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["LOG_LEVEL","counter","WebGLDevice","props","clientWidth","clientHeight","devicePixelRatio","device","gl","Error","id","canvasContext","WebGLCanvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","canvas","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","log","args","debug","webgl2","throwOnError","level","Math","max","warn","spector","type","vendor","renderer","probe","groupEnd","_features","_limits","_webglLimits","ext","getExtension","destroy","loseContext","isContextLost","drawingBufferWidth","drawingBufferHeight","format","ClassicBuffer","WEBGLTexture","WEBGLSampler","WEBGLShader","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLRenderPass","renderPass","beginRenderPass","framebuffer","getCurrentFramebuffer","endPass","WebGLRenderingContext","Device","isWebGL","groupCollapsed","CanvasContext","pageLoaded","attach","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA0BA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;;IAGqBC,W;;;;;AAwHnB,uBAAYC,KAAZ,EAAgC;AAAA;;AAAA;;AAAA;AAC9B,8BAAMA,KAAN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CAACpE,EAAE,IAAIqE,MAAM,CAACC,QAAP,CAAgBtE,EAAE,CAACmB,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBhB,EAAlB,EAAoC;AAClC,MAAI,OAAOmE,sBAAP,KAAkC,WAAlC,IAAiDnE,EAAE,YAAYmE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACpE,EAAE,IAAIA,EAAE,CAACmB,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/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} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\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';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\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 // 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 get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _webglLimits?: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\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 (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.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 return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\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 this.canvasContext = new WebGLCanvasContext(this, props);\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;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : 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\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 // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\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() {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n */\n loseDevice() {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\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): WEBGLBuffer {\n return new ClassicBuffer(this, props);\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 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('compute shaders not supported in WebGL');\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 /**\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?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\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"],"file":"webgl-device.js"}
1
+ {"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["LOG_LEVEL","counter","WebGLDevice","props","clientWidth","clientHeight","devicePixelRatio","device","gl","Error","id","canvasContext","WebGLCanvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","canvas","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","log","args","debug","webgl2","throwOnError","level","Math","max","warn","spector","type","vendor","renderer","probe","groupEnd","_features","_limits","ext","getExtension","destroy","isContextLost","drawingBufferWidth","drawingBufferHeight","format","ClassicBuffer","WEBGLTexture","WEBGLSampler","WEBGLShader","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLRenderPass","renderPass","beginRenderPass","framebuffer","getCurrentFramebuffer","endPass","_webglLimits","loseContext","WebGLRenderingContext","Device","isWebGL","groupCollapsed","CanvasContext","pageLoaded","attach","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA0BA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;;IAGqBC,W;;;;;AAyFnB,uBAAYC,KAAZ,EAAgC;AAAA;;AAAA;;AAAA;AAC9B,8BAAMA,KAAN;AAD8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6FA0Ka,IA1Kb;AAAA;AAAA,sFAuMc,IAvMd;AAAA,wFAwMN,KAxMM;AAAA;AAAA;AAAA,kGAgNL;AAACC,MAAAA,WAAW,EAAE,CAAd;AAAiBC,MAAAA,YAAY,EAAE,CAA/B;AAAkCC,MAAAA,gBAAgB,EAAE;AAApD,KAhNK;AAAA,8FAkNY,EAlNZ;AAAA,8FAmNT,KAnNS;AAAA;AAAA;AAK9B,QAAMC,MAA+B,gBAAGJ,KAAK,CAACK,EAAT,8CAAG,UAAUD,MAAlD;;AACA,QAAIA,MAAJ,EAAY;AACV,YAAM,IAAIE,KAAJ,oDAAsDF,MAAM,CAACG,EAA7D,EAAN;AACD;;AAGD,UAAKC,aAAL,GAAqB,IAAIC,2BAAJ,8CAA6BT,KAA7B,CAArB;AAEA,UAAKU,IAAL,GAAY,IAAIC,OAAJ,CAAoD,UAACC,OAAD,EAAa;AAC3E,YAAKC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AACoC,OAdZ;AAAA;AAAA;AAAA;;AAAA;AAAA,uBAeU,6BAfV;;AAAA;AAkBET,yBAAIa,KAAJ,CAAU3C,SAAS,GAAG,CAAtB,EAAyB,eAAzB;;AAlBF,sBAqBMG,KAAK,CAACK,EAAN,IAAYL,KAAK,CAACK,EAAN,CAASD,MArB3B;AAAA;AAAA;AAAA;;AAAA,iDAsBWL,WAAW,CAACwE,MAAZ,CAAmBvE,KAAK,CAACK,EAAzB,CAtBX;;AAAA;AAAA,iDAyBS,IAAIN,WAAJ,CAAgBC,KAAhB,CAzBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAzDuCkE,W;;;8BAApBnE,W,UAKG,O;;AAiVxB,SAASoE,OAAT,CAAiB9D,EAAjB,EAAmC;AACjC,MAAI,OAAO4D,qBAAP,KAAiC,WAAjC,IAAgD5D,EAAE,YAAY4D,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOO,sBAAP,KAAkC,WAAlC,IAAiDnE,EAAE,YAAYmE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACpE,EAAE,IAAIqE,MAAM,CAACC,QAAP,CAAgBtE,EAAE,CAACmB,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBhB,EAAlB,EAAoC;AAClC,MAAI,OAAOmE,sBAAP,KAAkC,WAAlC,IAAiDnE,EAAE,YAAYmE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACpE,EAAE,IAAIA,EAAE,CAACmB,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {popContextState, pushContextState, trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/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} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\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';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\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 (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.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 return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\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 this.canvasContext = new WebGLCanvasContext(this, props);\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;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : 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\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 // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\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() {\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): WEBGLBuffer {\n return new ClassicBuffer(this, props);\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 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('compute shaders not supported in WebGL');\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 /**\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?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\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 /** State used by luma.gl classes */\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 * Loses the context\n * @note Triggers context loss, mainly for testing\n * @todo Promote to `Device` API?\n */\n loseDevice(): void {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\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/** 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"],"file":"webgl-device.js"}
@@ -15,11 +15,6 @@ function getContextState(gl) {
15
15
 
16
16
  if (!luma) {
17
17
  var contextState = {
18
- _canvasSizeInfo: {
19
- clientWidth: 0,
20
- clientHeight: 0,
21
- devicePixelRatio: 1
22
- },
23
18
  _polyfilled: false,
24
19
  _extensions: {}
25
20
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_polyfilled","_extensions","Error"],"mappings":";;;;;;;AAiBO,SAASA,eAAT,CAAyBC,EAAzB,EAAkE;AAEvE,MAAOC,MAAP,GAAuBD,EAAvB,CAAOC,MAAP;AAAA,MAAeC,IAAf,GAAuBF,EAAvB,CAAeE,IAAf;;AACA,MAAID,MAAJ,EAAY;AACV,WAAOA,MAAP;AACD;;AACD,MAAI,CAACC,IAAL,EAAW;AACT,QAAMC,YAA0B,GAAG;AACjCC,MAAAA,eAAe,EAAE;AACfC,QAAAA,WAAW,EAAE,CADE;AAEfC,QAAAA,YAAY,EAAE,CAFC;AAGfC,QAAAA,gBAAgB,EAAE;AAHH,OADgB;AAMjCC,MAAAA,WAAW,EAAE,KANoB;AAOjCC,MAAAA,WAAW,EAAE;AAPoB,KAAnC;AAUAT,IAAAA,EAAE,CAACE,IAAH,GAAUC,YAAV;AACD;;AACD,QAAM,IAAIO,KAAJ,CAAU,8BAAV,CAAN;AAID","sourcesContent":["/**\n * Stores luma.gl specific state associated with a context\n */\nexport interface ContextState {\n _canvasSizeInfo: {\n clientWidth: number;\n clientHeight: number;\n devicePixelRatio: number;\n };\n _polyfilled: boolean;\n _extensions: Record<string, any>;\n}\n\n/**\n * Gets luma.gl specific state from a context\n * @returns context state\n */\nexport function getContextState(gl: WebGLRenderingContext): ContextState {\n // @ts-expect-error\n const {device, luma} = gl;\n if (device) {\n return device as ContextState;\n }\n if (!luma) {\n const contextState: ContextState = {\n _canvasSizeInfo: {\n clientWidth: 0,\n clientHeight: 0,\n devicePixelRatio: 1,\n },\n _polyfilled: false,\n _extensions: {}\n };\n // @ts-expect-error\n gl.luma = contextState;\n }\n throw new Error('context state without device');\n\n // // @ts-expect-error\n // return gl.luma;\n}\n"],"file":"context-state.js"}
1
+ {"version":3,"sources":["../../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_polyfilled","_extensions","Error"],"mappings":";;;;;;;AAYO,SAASA,eAAT,CAAyBC,EAAzB,EAAkE;AAEvE,MAAOC,MAAP,GAAuBD,EAAvB,CAAOC,MAAP;AAAA,MAAeC,IAAf,GAAuBF,EAAvB,CAAeE,IAAf;;AACA,MAAID,MAAJ,EAAY;AACV,WAAOA,MAAP;AACD;;AACD,MAAI,CAACC,IAAL,EAAW;AACT,QAAMC,YAA0B,GAAG;AACjCC,MAAAA,WAAW,EAAE,KADoB;AAEjCC,MAAAA,WAAW,EAAE;AAFoB,KAAnC;AAKAL,IAAAA,EAAE,CAACE,IAAH,GAAUC,YAAV;AACD;;AACD,QAAM,IAAIG,KAAJ,CAAU,8BAAV,CAAN;AAID","sourcesContent":["/**\n * Stores luma.gl specific state associated with a context\n */\nexport interface ContextState {\n _polyfilled: boolean;\n _extensions: Record<string, any>;\n}\n\n/**\n * Gets luma.gl specific state from a context\n * @returns context state\n */\nexport function getContextState(gl: WebGLRenderingContext): ContextState {\n // @ts-expect-error\n const {device, luma} = gl;\n if (device) {\n return device as ContextState;\n }\n if (!luma) {\n const contextState: ContextState = {\n _polyfilled: false,\n _extensions: {}\n };\n // @ts-expect-error\n gl.luma = contextState;\n }\n throw new Error('context state without device');\n\n // // @ts-expect-error\n // return gl.luma;\n}\n"],"file":"context-state.js"}
package/dist/es5/index.js CHANGED
@@ -143,18 +143,6 @@ Object.defineProperty(exports, "assertWebGL2Context", {
143
143
  return _webglChecks.assertWebGL2Context;
144
144
  }
145
145
  });
146
- Object.defineProperty(exports, "cssToDeviceRatio", {
147
- enumerable: true,
148
- get: function get() {
149
- return _devicePixels.cssToDeviceRatio;
150
- }
151
- });
152
- Object.defineProperty(exports, "cssToDevicePixels", {
153
- enumerable: true,
154
- get: function get() {
155
- return _devicePixels.cssToDevicePixels;
156
- }
157
- });
158
146
  Object.defineProperty(exports, "setDeviceParameters", {
159
147
  enumerable: true,
160
148
  get: function get() {
@@ -272,8 +260,6 @@ var _buffer = _interopRequireDefault(require("./classic/buffer"));
272
260
 
273
261
  var _webglChecks = require("./context/context/webgl-checks");
274
262
 
275
- var _devicePixels = require("./context/context/device-pixels");
276
-
277
263
  var _deviceParameters = require("./adapter/converters/device-parameters");
278
264
 
279
265
  var _unifiedParameterApi = require("./context/parameters/unified-parameter-api");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;AACA;;AAKA;;AAGA;;AACA;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAKA;;AACA;;AAGA;;AAGA;;AAEA;;AASA;;AAIA;;AAGA;;AAMA;;AAKA;;AAOA;;AAGA;;AACA","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;AACA;;AAKA;;AAGA;;AACA;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAKA;;AACA;;AAGA;;AAGA;;AAEA;;AAUA;;AAGA;;AAMA;;AAKA;;AAOA;;AAGA;;AACA","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { CanvasContext } from '@luma.gl/api';
3
- import { getDevicePixelRatio, setDevicePixelRatio } from '../context/context/device-pixels';
4
3
  import WEBGLFramebuffer from './resources/webgl-framebuffer';
5
4
  export default class WebGLCanvasContext extends CanvasContext {
6
5
  constructor(device, props) {
@@ -36,8 +35,7 @@ export default class WebGLCanvasContext extends CanvasContext {
36
35
 
37
36
  resize(options) {
38
37
  if (this.canvas) {
39
- const devicePixelRatio = getDevicePixelRatio(options === null || options === void 0 ? void 0 : options.useDevicePixels);
40
- setDevicePixelRatio(this.device.gl, devicePixelRatio, options);
38
+ this.setDevicePixelRatio(devicePixelRatio, options);
41
39
  return;
42
40
  }
43
41
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/webgl-canvas-context.ts"],"names":["CanvasContext","getDevicePixelRatio","setDevicePixelRatio","WEBGLFramebuffer","WebGLCanvasContext","constructor","device","props","presentationSize","update","getCurrentFramebuffer","_framebuffer","handle","size","getPixelSize","sizeChanged","resize","options","canvas","devicePixelRatio","useDevicePixels","gl","ext","getExtension","width","height","commit"],"mappings":";AAEA,SAAQA,aAAR,QAA4B,cAA5B;AACA,SAAQC,mBAAR,EAA6BC,mBAA7B,QAAuD,kCAAvD;AAEA,OAAOC,gBAAP,MAA6B,+BAA7B;AAMA,eAAe,MAAMC,kBAAN,SAAiCJ,aAAjC,CAA+C;AAK5DK,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAtB,EAAiD;AAE1D,UAAMA,KAAN;;AAF0D;;AAAA;;AAAA,0CAFZ,IAEY;;AAG1D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,gBAAL,GAAwB,CAAC,CAAC,CAAF,EAAK,CAAC,CAAN,CAAxB;AACA,SAAKC,MAAL;AACD;;AAEDC,EAAAA,qBAAqB,GAAqB;AACxC,SAAKD,MAAL;AACA,SAAKE,YAAL,GAAoB,KAAKA,YAAL,IAAqB,IAAIR,gBAAJ,CAAqB,KAAKG,MAA1B,EAAkC;AAACM,MAAAA,MAAM,EAAE;AAAT,KAAlC,CAAzC;AACA,WAAO,KAAKD,YAAZ;AACD;;AAGDF,EAAAA,MAAM,GAAG;AACP,UAAMI,IAAI,GAAG,KAAKC,YAAL,EAAb;AACA,UAAMC,WAAW,GAAGF,IAAI,CAAC,CAAD,CAAJ,KAAY,KAAKL,gBAAL,CAAsB,CAAtB,CAAZ,IAAwCK,IAAI,CAAC,CAAD,CAAJ,KAAY,KAAKL,gBAAL,CAAsB,CAAtB,CAAxE;;AACA,QAAIO,WAAJ,EAAiB;AACf,WAAKP,gBAAL,GAAwBK,IAAxB;AACD;AACF;;AAcAG,EAAAA,MAAM,CAACC,OAAD,EAAwF;AAE7F,QAAI,KAAKC,MAAT,EAAiB;AACf,YAAMC,gBAAgB,GAAGlB,mBAAmB,CAACgB,OAAD,aAACA,OAAD,uBAACA,OAAO,CAAEG,eAAV,CAA5C;AACAlB,MAAAA,mBAAmB,CAAC,KAAKI,MAAL,CAAYe,EAAb,EAAiBF,gBAAjB,EAAmCF,OAAnC,CAAnB;AACA;AACD;;AAGD,UAAMK,GAAG,GAAG,KAAKhB,MAAL,CAAYe,EAAZ,CAAeE,YAAf,CAA4B,8BAA5B,CAAZ;;AACA,QAAID,GAAG,IAAIL,OAAP,IAAkB,WAAWA,OAA7B,IAAwC,YAAYA,OAAxD,EAAiE;AAC/DK,MAAAA,GAAG,CAACN,MAAJ,CAAWC,OAAO,CAACO,KAAnB,EAA0BP,OAAO,CAACQ,MAAlC;AACD;AACF;;AAEDC,EAAAA,MAAM,GAAG,CAMR;;AA7D2D","sourcesContent":["// luma.gl, MIT license\nimport type {CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext} from '@luma.gl/api';\nimport {getDevicePixelRatio, setDevicePixelRatio} from '../context/context/device-pixels';\nimport WebGLDevice from './webgl-device';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\n\n/** \n * Holds a WebGL Canvas Context which will handle drawing buffer resizing etc \n * @todo This class is WIP, intended to replace the old gltools-based context size tracking\n */\nexport default class WebGLCanvasContext extends CanvasContext {\n readonly device: WebGLDevice;\n presentationSize: [number, number];\n private _framebuffer: WEBGLFramebuffer | null = null;\n\n constructor(device: WebGLDevice, props: CanvasContextProps) {\n // Note: Base class creates / looks up the canvas (unless under Node.js)\n super(props);\n this.device = device;\n this.presentationSize = [-1, -1];\n this.update();\n }\n\n getCurrentFramebuffer(): WEBGLFramebuffer {\n this.update();\n this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, {handle: null});\n return this._framebuffer;\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const size = this.getPixelSize();\n const sizeChanged = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];\n if (sizeChanged) {\n this.presentationSize = size;\n }\n }\n\n /**\n * Resize the canvas' drawing buffer.\n *\n * Can match the canvas CSS size, and optionally also consider devicePixelRatio\n * Can be called every frame\n *\n * Regardless of size, the drawing buffer will always be scaled to the viewport, but\n * for best visual results, usually set to either:\n * canvas CSS width x canvas CSS height\n * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio\n * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n */\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = getDevicePixelRatio(options?.useDevicePixels);\n setDevicePixelRatio(this.device.gl, devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = this.device.gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && `width` in options && `height` in options) {\n ext.resize(options.width, options.height);\n }\n }\n\n commit() {\n // gl.commit was ultimately removed from standard??\n // if (this.offScreen && this.gl.commit) {\n // // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n // this.gl.commit();\n // }\n }\n}\n"],"file":"webgl-canvas-context.js"}
1
+ {"version":3,"sources":["../../../src/adapter/webgl-canvas-context.ts"],"names":["CanvasContext","WEBGLFramebuffer","WebGLCanvasContext","constructor","device","props","presentationSize","update","getCurrentFramebuffer","_framebuffer","handle","size","getPixelSize","sizeChanged","resize","options","canvas","setDevicePixelRatio","devicePixelRatio","ext","gl","getExtension","width","height","commit"],"mappings":";AAEA,SAAQA,aAAR,QAA4B,cAA5B;AAEA,OAAOC,gBAAP,MAA6B,+BAA7B;AAMA,eAAe,MAAMC,kBAAN,SAAiCF,aAAjC,CAA+C;AAK5DG,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAtB,EAAiD;AAE1D,UAAMA,KAAN;;AAF0D;;AAAA;;AAAA,0CAFZ,IAEY;;AAG1D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,gBAAL,GAAwB,CAAC,CAAC,CAAF,EAAK,CAAC,CAAN,CAAxB;AACA,SAAKC,MAAL;AACD;;AAEDC,EAAAA,qBAAqB,GAAqB;AACxC,SAAKD,MAAL;AACA,SAAKE,YAAL,GAAoB,KAAKA,YAAL,IAAqB,IAAIR,gBAAJ,CAAqB,KAAKG,MAA1B,EAAkC;AAACM,MAAAA,MAAM,EAAE;AAAT,KAAlC,CAAzC;AACA,WAAO,KAAKD,YAAZ;AACD;;AAGDF,EAAAA,MAAM,GAAG;AACP,UAAMI,IAAI,GAAG,KAAKC,YAAL,EAAb;AACA,UAAMC,WAAW,GAAGF,IAAI,CAAC,CAAD,CAAJ,KAAY,KAAKL,gBAAL,CAAsB,CAAtB,CAAZ,IAAwCK,IAAI,CAAC,CAAD,CAAJ,KAAY,KAAKL,gBAAL,CAAsB,CAAtB,CAAxE;;AACA,QAAIO,WAAJ,EAAiB;AACf,WAAKP,gBAAL,GAAwBK,IAAxB;AACD;AACF;;AAcAG,EAAAA,MAAM,CAACC,OAAD,EAAwF;AAE7F,QAAI,KAAKC,MAAT,EAAiB;AACf,WAAKC,mBAAL,CAAyBC,gBAAzB,EAA2CH,OAA3C;AACA;AACD;;AAGD,UAAMI,GAAG,GAAG,KAAKf,MAAL,CAAYgB,EAAZ,CAAeC,YAAf,CAA4B,8BAA5B,CAAZ;;AACA,QAAIF,GAAG,IAAIJ,OAAP,IAAkB,WAAWA,OAA7B,IAAwC,YAAYA,OAAxD,EAAiE;AAC/DI,MAAAA,GAAG,CAACL,MAAJ,CAAWC,OAAO,CAACO,KAAnB,EAA0BP,OAAO,CAACQ,MAAlC;AACD;AACF;;AAEDC,EAAAA,MAAM,GAAG,CAMR;;AA5D2D","sourcesContent":["// luma.gl, MIT license\nimport type {CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext} from '@luma.gl/api';\nimport WebGLDevice from './webgl-device';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\n\n/** \n * Holds a WebGL Canvas Context which will handle drawing buffer resizing etc \n * @todo This class is WIP, intended to replace the old gltools-based context size tracking\n */\nexport default class WebGLCanvasContext extends CanvasContext {\n readonly device: WebGLDevice;\n presentationSize: [number, number];\n private _framebuffer: WEBGLFramebuffer | null = null;\n\n constructor(device: WebGLDevice, props: CanvasContextProps) {\n // Note: Base class creates / looks up the canvas (unless under Node.js)\n super(props);\n this.device = device;\n this.presentationSize = [-1, -1];\n this.update();\n }\n\n getCurrentFramebuffer(): WEBGLFramebuffer {\n this.update();\n this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, {handle: null});\n return this._framebuffer;\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const size = this.getPixelSize();\n const sizeChanged = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];\n if (sizeChanged) {\n this.presentationSize = size;\n }\n }\n\n /**\n * Resize the canvas' drawing buffer.\n *\n * Can match the canvas CSS size, and optionally also consider devicePixelRatio\n * Can be called every frame\n *\n * Regardless of size, the drawing buffer will always be scaled to the viewport, but\n * for best visual results, usually set to either:\n * canvas CSS width x canvas CSS height\n * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio\n * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n */\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n // Resize browser context .\n if (this.canvas) {\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = this.device.gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && `width` in options && `height` in options) {\n ext.resize(options.width, options.height);\n }\n }\n\n commit() {\n // gl.commit was ultimately removed from standard??\n // if (this.offScreen && this.gl.commit) {\n // // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n // this.gl.commit();\n // }\n }\n}\n"],"file":"webgl-canvas-context.js"}
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { Device, CanvasContext, log } from '@luma.gl/api';
3
3
  import { isBrowser } from '@probe.gl/env';
4
4
  import { polyfillContext } from '../context/polyfill/polyfill-context';
5
- import { trackContextState } from '../context/state-tracker/track-context-state';
5
+ import { popContextState, pushContextState, trackContextState } from '../context/state-tracker/track-context-state';
6
6
  import { createBrowserContext } from '../context/context/create-browser-context';
7
7
  import { createHeadlessContext, isHeadlessGLRegistered } from '../context/context/create-headless-context';
8
8
  import { getDeviceInfo } from './device-helpers/get-device-info';
@@ -36,11 +36,6 @@ export default class WebGLDevice extends Device {
36
36
  return this._limits;
37
37
  }
38
38
 
39
- get webglLimits() {
40
- this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
41
- return this._webglLimits;
42
- }
43
-
44
39
  static attach(gl) {
45
40
  if (gl instanceof WebGLDevice) {
46
41
  return gl;
@@ -102,6 +97,8 @@ export default class WebGLDevice extends Device {
102
97
 
103
98
  _defineProperty(this, "_limits", void 0);
104
99
 
100
+ _defineProperty(this, "renderPass", null);
101
+
105
102
  _defineProperty(this, "gl", void 0);
106
103
 
107
104
  _defineProperty(this, "gl2", null);
@@ -112,8 +109,6 @@ export default class WebGLDevice extends Device {
112
109
 
113
110
  _defineProperty(this, "isWebGL2", void 0);
114
111
 
115
- _defineProperty(this, "_webglLimits", void 0);
116
-
117
112
  _defineProperty(this, "_canvasSizeInfo", {
118
113
  clientWidth: 0,
119
114
  clientHeight: 0,
@@ -126,7 +121,7 @@ export default class WebGLDevice extends Device {
126
121
 
127
122
  _defineProperty(this, "spector", void 0);
128
123
 
129
- _defineProperty(this, "renderPass", null);
124
+ _defineProperty(this, "_webglLimits", void 0);
130
125
 
131
126
  const device = (_props$gl = props.gl) === null || _props$gl === void 0 ? void 0 : _props$gl.device;
132
127
 
@@ -210,21 +205,6 @@ export default class WebGLDevice extends Device {
210
205
  }
211
206
  }
212
207
 
213
- loseDevice() {
214
- var _this$_resolveContext2;
215
-
216
- const ext = this.gl.getExtension('WEBGL_lose_context');
217
-
218
- if (ext) {
219
- ext.loseContext();
220
- }
221
-
222
- (_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
223
- reason: 'destroyed',
224
- message: 'Application triggered context loss'
225
- });
226
- }
227
-
228
208
  get isLost() {
229
209
  return this.gl.isContextLost();
230
210
  }
@@ -311,6 +291,34 @@ export default class WebGLDevice extends Device {
311
291
  this.renderPass = null;
312
292
  }
313
293
 
294
+ get webglLimits() {
295
+ this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
296
+ return this._webglLimits;
297
+ }
298
+
299
+ loseDevice() {
300
+ var _this$_resolveContext2;
301
+
302
+ const ext = this.gl.getExtension('WEBGL_lose_context');
303
+
304
+ if (ext) {
305
+ ext.loseContext();
306
+ }
307
+
308
+ (_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
309
+ reason: 'destroyed',
310
+ message: 'Application triggered context loss'
311
+ });
312
+ }
313
+
314
+ pushState() {
315
+ pushContextState(this.gl);
316
+ }
317
+
318
+ popState() {
319
+ popContextState(this.gl);
320
+ }
321
+
314
322
  }
315
323
 
316
324
  _defineProperty(WebGLDevice, "type", 'webgl');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","isBrowser","polyfillContext","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","webglLimits","_webglLimits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","id","canvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","loseDevice","loseContext","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,iBAAR,QAAgC,8CAAhC;AAEA,SAAQC,oBAAR,QAAmC,2CAAnC;AACA,SACEC,qBADF,EAEEC,sBAFF,QAGO,4CAHP;AAIA,SAAQC,aAAR,QAA4B,kCAA5B;AACA,SAAQC,iBAAR,QAAgC,kCAAhC;AACA,SAAQC,eAAR,EAAyBC,cAAzB,QAA2D,gCAA3D;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,SAAQC,aAAR,EAAuBC,mBAAvB,QAAiD,0BAAjD;AACA,SAAQC,uBAAR,EAAiCC,gBAAjC,QAAwD,wCAAxD;AACA,SACEC,wBADF,EAEEC,yBAFF,EAGEC,yBAHF,QAIO,8BAJP;AA0BA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AACA,OAAOC,eAAP,MAA4B,+BAA5B;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AAEA,MAAMC,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;AAGA,eAAe,MAAMC,WAAN,SAA0B9B,MAA1B,CA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;;AAODG,EAAAA,MAAM,GAAS;AAAA;;AACb,6BAAKH,UAAL,sEAAiBI,OAAjB;AACA,SAAKJ,UAAL,GAAkB,IAAlB;AAED;;AAtUqE;;gBAAnD/E,W,UAKG,O;;AAqUxB,SAASY,OAAT,CAAiBP,EAAjB,EAAmC;AACjC,MAAI,OAAOH,qBAAP,KAAiC,WAAjC,IAAgDG,EAAE,YAAYH,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOkF,sBAAP,KAAkC,WAAlC,IAAiD/E,EAAE,YAAY+E,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAChF,EAAE,IAAIiF,MAAM,CAACC,QAAP,CAAgBlF,EAAE,CAACoC,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBjC,EAAlB,EAAoC;AAClC,MAAI,OAAO+E,sBAAP,KAAkC,WAAlC,IAAiD/E,EAAE,YAAY+E,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAChF,EAAE,IAAIA,EAAE,CAACoC,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/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} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\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';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\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 // 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 get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _webglLimits?: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\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 (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.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 return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\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 this.canvasContext = new WebGLCanvasContext(this, props);\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;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : 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\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 // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\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() {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n */\n loseDevice() {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\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): WEBGLBuffer {\n return new ClassicBuffer(this, props);\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 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('compute shaders not supported in WebGL');\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 /**\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?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\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"],"file":"webgl-device.js"}
1
+ {"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","id","canvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","webglLimits","_webglLimits","loseDevice","loseContext","pushState","popState","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,eAAR,EAAyBC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O,IAAP;AACD;;AACD,MAAI,OAAOoF,sBAAP,KAAkC,WAAlC,IAAiDjF,EAAE,YAAYiF,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAClF,EAAE,IAAImF,MAAM,CAACC,QAAP,CAAgBpF,EAAE,CAACkC,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkB/B,EAAlB,EAAoC;AAClC,MAAI,OAAOiF,sBAAP,KAAkC,WAAlC,IAAiDjF,EAAE,YAAYiF,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAClF,EAAE,IAAIA,EAAE,CAACkC,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {popContextState, pushContextState, trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/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} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\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';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\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 (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.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 return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\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 this.canvasContext = new WebGLCanvasContext(this, props);\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;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : 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\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 // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\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() {\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): WEBGLBuffer {\n return new ClassicBuffer(this, props);\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 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('compute shaders not supported in WebGL');\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 /**\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?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\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 /** State used by luma.gl classes */\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 * Loses the context\n * @note Triggers context loss, mainly for testing\n * @todo Promote to `Device` API?\n */\n loseDevice(): void {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\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/** 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"],"file":"webgl-device.js"}
@@ -10,11 +10,6 @@ export function getContextState(gl) {
10
10
 
11
11
  if (!luma) {
12
12
  const contextState = {
13
- _canvasSizeInfo: {
14
- clientWidth: 0,
15
- clientHeight: 0,
16
- devicePixelRatio: 1
17
- },
18
13
  _polyfilled: false,
19
14
  _extensions: {}
20
15
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_polyfilled","_extensions","Error"],"mappings":"AAiBA,OAAO,SAASA,eAAT,CAAyBC,EAAzB,EAAkE;AAEvE,QAAM;AAACC,IAAAA,MAAD;AAASC,IAAAA;AAAT,MAAiBF,EAAvB;;AACA,MAAIC,MAAJ,EAAY;AACV,WAAOA,MAAP;AACD;;AACD,MAAI,CAACC,IAAL,EAAW;AACT,UAAMC,YAA0B,GAAG;AACjCC,MAAAA,eAAe,EAAE;AACfC,QAAAA,WAAW,EAAE,CADE;AAEfC,QAAAA,YAAY,EAAE,CAFC;AAGfC,QAAAA,gBAAgB,EAAE;AAHH,OADgB;AAMjCC,MAAAA,WAAW,EAAE,KANoB;AAOjCC,MAAAA,WAAW,EAAE;AAPoB,KAAnC;AAUAT,IAAAA,EAAE,CAACE,IAAH,GAAUC,YAAV;AACD;;AACD,QAAM,IAAIO,KAAJ,CAAU,8BAAV,CAAN;AAID","sourcesContent":["/**\n * Stores luma.gl specific state associated with a context\n */\nexport interface ContextState {\n _canvasSizeInfo: {\n clientWidth: number;\n clientHeight: number;\n devicePixelRatio: number;\n };\n _polyfilled: boolean;\n _extensions: Record<string, any>;\n}\n\n/**\n * Gets luma.gl specific state from a context\n * @returns context state\n */\nexport function getContextState(gl: WebGLRenderingContext): ContextState {\n // @ts-expect-error\n const {device, luma} = gl;\n if (device) {\n return device as ContextState;\n }\n if (!luma) {\n const contextState: ContextState = {\n _canvasSizeInfo: {\n clientWidth: 0,\n clientHeight: 0,\n devicePixelRatio: 1,\n },\n _polyfilled: false,\n _extensions: {}\n };\n // @ts-expect-error\n gl.luma = contextState;\n }\n throw new Error('context state without device');\n\n // // @ts-expect-error\n // return gl.luma;\n}\n"],"file":"context-state.js"}
1
+ {"version":3,"sources":["../../../../src/context/context/context-state.ts"],"names":["getContextState","gl","device","luma","contextState","_polyfilled","_extensions","Error"],"mappings":"AAYA,OAAO,SAASA,eAAT,CAAyBC,EAAzB,EAAkE;AAEvE,QAAM;AAACC,IAAAA,MAAD;AAASC,IAAAA;AAAT,MAAiBF,EAAvB;;AACA,MAAIC,MAAJ,EAAY;AACV,WAAOA,MAAP;AACD;;AACD,MAAI,CAACC,IAAL,EAAW;AACT,UAAMC,YAA0B,GAAG;AACjCC,MAAAA,WAAW,EAAE,KADoB;AAEjCC,MAAAA,WAAW,EAAE;AAFoB,KAAnC;AAKAL,IAAAA,EAAE,CAACE,IAAH,GAAUC,YAAV;AACD;;AACD,QAAM,IAAIG,KAAJ,CAAU,8BAAV,CAAN;AAID","sourcesContent":["/**\n * Stores luma.gl specific state associated with a context\n */\nexport interface ContextState {\n _polyfilled: boolean;\n _extensions: Record<string, any>;\n}\n\n/**\n * Gets luma.gl specific state from a context\n * @returns context state\n */\nexport function getContextState(gl: WebGLRenderingContext): ContextState {\n // @ts-expect-error\n const {device, luma} = gl;\n if (device) {\n return device as ContextState;\n }\n if (!luma) {\n const contextState: ContextState = {\n _polyfilled: false,\n _extensions: {}\n };\n // @ts-expect-error\n gl.luma = contextState;\n }\n throw new Error('context state without device');\n\n // // @ts-expect-error\n // return gl.luma;\n}\n"],"file":"context-state.js"}
package/dist/esm/index.js CHANGED
@@ -17,7 +17,6 @@ export { default as WEBGLVertexArrayObject } from './adapter/objects/webgl-verte
17
17
  export { default as Accessor } from './classic/accessor';
18
18
  export { default as ClassicBuffer, default as Buffer } from './classic/buffer';
19
19
  export { isWebGL, isWebGL2, getWebGL2Context, assertWebGLContext, assertWebGL2Context } from './context/context/webgl-checks';
20
- export { cssToDeviceRatio, cssToDevicePixels } from './context/context/device-pixels';
21
20
  export { setDeviceParameters, withDeviceParameters } from './adapter/converters/device-parameters';
22
21
  export { getParameters, setParameters, resetParameters } from './context/parameters/unified-parameter-api';
23
22
  export { withParameters } from './context/state-tracker/with-parameters';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAGA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AASA,SAAQC,gBAAR,EAA0BC,iBAA1B,QAAkD,iCAAlD;AAIA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAGA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AAUA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
package/dist/index.d.ts CHANGED
@@ -21,7 +21,6 @@ export type { AccessorObject } from './types';
21
21
  export type { ClassicBufferProps, ClassicBufferProps as BufferProps } from './classic/buffer';
22
22
  export { default as ClassicBuffer, default as Buffer } from './classic/buffer';
23
23
  export { isWebGL, isWebGL2, getWebGL2Context, assertWebGLContext, assertWebGL2Context } from './context/context/webgl-checks';
24
- export { cssToDeviceRatio, cssToDevicePixels } from './context/context/device-pixels';
25
24
  export { setDeviceParameters, withDeviceParameters } from './adapter/converters/device-parameters';
26
25
  export type { GLParameters } from './types/webgl';
27
26
  export { getParameters, setParameters, resetParameters } from './context/parameters/unified-parameter-api';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,CAAC;AACtB,OAAO,QAAQ,CAAA;AAGf,YAAY,EAAC,WAAW,EAAC,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAC,kBAAkB,EAAC,MAAM,2CAA2C,CAAC;AAG7E,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,OAAO,IAAI,aAAa,EAAC,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAEzF,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,uCAAuC,CAAC;AAIjF,YAAY,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,OAAO,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;AAE7E,OAAO,EACL,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gCAAgC,CAAC;AAIxC,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjG,YAAY,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,cAAc,EACf,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAC,4BAA4B,EAAC,MAAM,sCAAsC,CAAC"}
package/dist/index.js CHANGED
@@ -17,7 +17,6 @@ export { default as WEBGLVertexArrayObject } from './adapter/objects/webgl-verte
17
17
  export { default as Accessor } from './classic/accessor';
18
18
  export { default as ClassicBuffer, default as Buffer } from './classic/buffer';
19
19
  export { isWebGL, isWebGL2, getWebGL2Context, assertWebGLContext, assertWebGL2Context } from './context/context/webgl-checks';
20
- export { cssToDeviceRatio, cssToDevicePixels } from './context/context/device-pixels';
21
20
  export { setDeviceParameters, withDeviceParameters } from './adapter/converters/device-parameters';
22
21
  export { getParameters, setParameters, resetParameters } from './context/parameters/unified-parameter-api';
23
22
  export { withParameters } from './context/state-tracker/with-parameters';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAGA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AASA,SAAQC,gBAAR,EAA0BC,iBAA1B,QAAkD,iCAAlD;AAIA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["registerHeadlessGL","default","WebGLDevice","WebGLCanvasContext","WEBGLResource","WebGLResource","WEBGLBuffer","WEBGLTexture","WEBGLShader","WEBGLSampler","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLRenderPass","WEBGLRenderbuffer","WEBGLVertexArrayObject","Accessor","ClassicBuffer","Buffer","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","setDeviceParameters","withDeviceParameters","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","getShaderLayout","getProgramBindings","_checkFloat32ColorAttachment"],"mappings":"AAOA,OAAO,cAAP;AACA,OAAO,QAAP;AAKA,SAAQA,kBAAR,QAAiC,2CAAjC;AAGA,SAAQC,OAAO,IAAIC,WAAnB,QAAqC,wBAArC;AACA,SAAQD,OAAO,IAAIE,kBAAnB,QAA4C,gCAA5C;AAGA,SAAQF,OAAO,IAAIG,aAAnB,EAAkCH,OAAO,IAAII,aAA7C,QAAiE,kCAAjE;AACA,SAAQJ,OAAO,IAAIK,WAAnB,QAAqC,kCAArC;AACA,SAAQL,OAAO,IAAIM,YAAnB,QAAsC,mCAAtC;AAEA,SAAQN,OAAO,IAAIO,WAAnB,QAAqC,kCAArC;AACA,SAAQP,OAAO,IAAIQ,YAAnB,QAAsC,mCAAtC;AACA,SAAQR,OAAO,IAAIS,gBAAnB,QAA0C,uCAA1C;AAEA,SAAQT,OAAO,IAAIU,mBAAnB,QAA6C,2CAA7C;AAEA,SAAQV,OAAO,IAAIW,mBAAnB,QAA6C,2CAA7C;AACA,SAAQX,OAAO,IAAIY,eAAnB,QAAyC,uCAAzC;AAKA,SAAQZ,OAAO,IAAIa,iBAAnB,QAA2C,sCAA3C;AACA,SAAQb,OAAO,IAAIc,sBAAnB,QAAgD,6CAAhD;AAGA,SAAQd,OAAO,IAAIe,QAAnB,QAAkC,oBAAlC;AAGA,SAAQf,OAAO,IAAIgB,aAAnB,EAAkChB,OAAO,IAAIiB,MAA7C,QAA0D,kBAA1D;AAEA,SACEC,OADF,EAEEC,QAFF,EAGEC,gBAHF,EAIEC,kBAJF,EAKEC,mBALF,QAMO,gCANP;AAUA,SAAQC,mBAAR,EAA6BC,oBAA7B,QAAwD,wCAAxD;AAGA,SACEC,aADF,EAEEC,aAFF,EAGEC,eAHF,QAIO,4CAJP;AAMA,SACEC,cADF,QAEO,yCAFP;AAKA,SACEC,iBADF,EAEEC,gBAFF,EAGEC,eAHF,QAIO,6CAJP;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,eAAR,EAAyBC,kBAAzB,QAAkD,qCAAlD;AACA,SAAQC,4BAAR,QAA2C,sCAA3C","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}