From 59b8ef3852ec5ad6ef3f72143e4fc24613f33def Mon Sep 17 00:00:00 2001 From: Ib Green Date: Mon, 26 Aug 2024 09:17:26 -0400 Subject: [PATCH] wip --- .../src/deprecated/sync-test-device.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 modules/test-utils/src/deprecated/sync-test-device.ts diff --git a/modules/test-utils/src/deprecated/sync-test-device.ts b/modules/test-utils/src/deprecated/sync-test-device.ts new file mode 100644 index 0000000000..4c313af976 --- /dev/null +++ b/modules/test-utils/src/deprecated/sync-test-device.ts @@ -0,0 +1,35 @@ +// luma.gl +// SPDX-License +// Copyright (c) vis.gl contributors + +import type {CanvasContextProps} from '@luma.gl/core'; +import {WebGLDevice} from '@luma.gl/webgl'; + +const DEFAULT_CANVAS_CONTEXT_PROPS: CanvasContextProps = { + width: 1, + height: 1 +}; + +/** + * Create a test WebGLDevice + * @note This WebGL Device is create synchronously and can be used directly but will not have WebGL debugging initialized + * @deprecated Use getWebGLTestDevice(). + */ +export function createTestDevice(): WebGLDevice | null { + try { + // TODO - We do not use luma.createDevice since createTestDevice currently expect WebGL context to be created synchronously + return new WebGLDevice({createCanvasContext: DEFAULT_CANVAS_CONTEXT_PROPS}); + } catch (error) { + // eslint-disable-next-line no-console + console.error(`Failed to created device: ${(error as Error).message}`); + debugger; // eslint-disable-line no-debugger + return null; + } +} + +/** + * A pre-created WebGLDevice + * @note This WebGL Device is create synchronously and can be used directly but will not have WebGL debugging initialized + * @deprecated Use getWebGLTestDevice(). + */ +export const webglDevice = createTestDevice();