From eccb6b1ca1a498de34ab4a08ec6da02207642b3f Mon Sep 17 00:00:00 2001 From: felixpalmer Date: Tue, 30 Sep 2025 18:04:21 +0200 Subject: [PATCH] fix(webgl): WebGLAdapter.attach support passing DeviceProps (#2453) (#2454) --- modules/webgl/src/adapter/webgl-adapter.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/webgl/src/adapter/webgl-adapter.ts b/modules/webgl/src/adapter/webgl-adapter.ts index 3d9ecd687..b0ac1a127 100644 --- a/modules/webgl/src/adapter/webgl-adapter.ts +++ b/modules/webgl/src/adapter/webgl-adapter.ts @@ -50,7 +50,7 @@ export class WebGLAdapter extends Adapter { * @param gl * @returns */ - async attach(gl: Device | WebGL2RenderingContext): Promise { + async attach(gl: Device | WebGL2RenderingContext, props: DeviceProps = {}): Promise { const {WebGLDevice} = await import('./webgl-device'); if (gl instanceof WebGLDevice) { return gl; @@ -64,11 +64,14 @@ export class WebGLAdapter extends Adapter { throw new Error('Invalid WebGL2RenderingContext'); } + const createCanvasContext = props.createCanvasContext === true ? {} : props.createCanvasContext; + // We create a new device using the provided WebGL context and its canvas // Assume that whoever created the external context will be handling resizes. return new WebGLDevice({ + ...props, _handle: gl, - createCanvasContext: {canvas: gl.canvas, autoResize: false} + createCanvasContext: {canvas: gl.canvas, autoResize: false, ...createCanvasContext} }); }