@pixi/core
Version:
Core PixiJS
1 lines • 1.78 kB
Source Map (JSON)
{"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,CAAA;AACvB,IAAI,UAA0D;AAQvD,SAAS,iBAChB;AACI,MAAI,YAAY,kBAAkB,SAAS,cAAA,GAC3C;AACU,UAAA,SAAS,SAAS,QAAQ,aAAa;AAEzC,QAAA;AAEA,aAAS,cAAc,IAAI,WAE3B,KAAK,OAAO,WAAW,UAAU,CAAA,CAAE,IAGlC,OAED,KAAM,OAAO,WAAW,SAAS,CAAA,CAAE,KAC3B,OAAO,WAAW,sBAAsB,CAAE,CAAA,GAE7C,KAQD,GAAG,aAAa,oBAAoB,IALpC,KAAK,OASb,UAAU;AAAA,EACd;AAEO,SAAA;AACX;"}