UNPKG

722 BJavaScriptView Raw
1import { ENV } from '@pixi/constants';
2import { settings } from '@pixi/settings';
3
4const unknownContext = {};
5let context = unknownContext;
6function getTestContext() {
7 if (context === unknownContext || context?.isContextLost()) {
8 const canvas = settings.ADAPTER.createCanvas();
9 let gl;
10 if (settings.PREFER_ENV >= ENV.WEBGL2) {
11 gl = canvas.getContext("webgl2", {});
12 }
13 if (!gl) {
14 gl = canvas.getContext("webgl", {}) || canvas.getContext("experimental-webgl", {});
15 if (!gl) {
16 gl = null;
17 } else {
18 gl.getExtension("WEBGL_draw_buffers");
19 }
20 }
21 context = gl;
22 }
23 return context;
24}
25
26export { getTestContext };
27//# sourceMappingURL=getTestContext.mjs.map