UNPKG

2.15 kBSource Map (JSON)View Raw
1{"version":3,"file":"getTestContext.mjs","sources":["../../../src/shader/utils/getTestContext.ts"],"sourcesContent":["import { ENV } from '@pixi/constants';\nimport { settings } from '@pixi/settings';\n\nconst unknownContext = {};\nlet context: WebGLRenderingContext | WebGL2RenderingContext = unknownContext as any;\n\n/**\n * returns a little WebGL context to use for program inspection.\n * @static\n * @private\n * @returns {WebGLRenderingContext} a gl context to test with\n */\nexport function getTestContext(): WebGLRenderingContext | WebGL2RenderingContext\n{\n if (context === unknownContext || context?.isContextLost())\n {\n const canvas = settings.ADAPTER.createCanvas();\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext;\n\n if (settings.PREFER_ENV >= ENV.WEBGL2)\n {\n gl = canvas.getContext('webgl2', {});\n }\n\n if (!gl)\n {\n gl = (canvas.getContext('webgl', {})\n || (canvas.getContext('experimental-webgl', {}) as WebGLRenderingContext));\n\n if (!gl)\n {\n // fail, not able to get a context\n gl = null;\n }\n else\n {\n // for shader testing..\n gl.getExtension('WEBGL_draw_buffers');\n }\n }\n\n context = gl;\n }\n\n return context;\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,iBAAiB,EAAC,CAAA;AACxB,IAAI,OAA0D,GAAA,cAAA,CAAA;AAS9D,SAAA,cAAA,GAAA;AACI,EAAA,IAAI,OAAY,KAAA,cAAA,IAAkB,OAAS,EAAA,aAAA,EAC3C,EAAA;AACI,IAAM,MAAA,MAAA,GAAS,QAAS,CAAA,OAAA,CAAQ,YAAa,EAAA,CAAA;AAE7C,IAAI,IAAA,EAAA,CAAA;AAEJ,IAAI,IAAA,QAAA,CAAS,UAAc,IAAA,GAAA,CAAI,MAC/B,EAAA;AACI,MAAA,EAAA,GAAK,MAAO,CAAA,UAAA,CAAW,QAAU,EAAA,EAAE,CAAA,CAAA;AAAA,KACvC;AAEA,IAAA,IAAI,CAAC,EACL,EAAA;AACI,MAAM,EAAA,GAAA,MAAA,CAAO,UAAW,CAAA,OAAA,EAAS,EAAE,KAC3B,MAAO,CAAA,UAAA,CAAW,oBAAsB,EAAA,EAAE,CAAA,CAAA;AAElD,MAAA,IAAI,CAAC,EACL,EAAA;AAEI,QAAK,EAAA,GAAA,IAAA,CAAA;AAAA,OAGT,MAAA;AAEI,QAAA,EAAA,CAAG,aAAa,oBAAoB,CAAA,CAAA;AAAA,OACxC;AAAA,KACJ;AAEA,IAAU,OAAA,GAAA,EAAA,CAAA;AAAA,GACd;AAEA,EAAO,OAAA,OAAA,CAAA;AACX;;;;"}
\No newline at end of file