FIx bug and bump version
This commit is contained in:
parent
e8cd979f53
commit
f60ae06f59
2 changed files with 17 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sdf-2d",
|
"name": "sdf-2d",
|
||||||
"version": "0.1.1-alpha",
|
"version": "0.1.2-alpha",
|
||||||
"description": "Graphics framework for efficiently rendering 2D signed distance fields.",
|
"description": "Graphics framework for efficiently rendering 2D signed distance fields.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"webgl",
|
"webgl",
|
||||||
|
|
|
||||||
|
|
@ -7,28 +7,27 @@ export const getUniversalRenderingContext = (
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
ignoreWebGL2 = false
|
ignoreWebGL2 = false
|
||||||
): UniversalRenderingContext => {
|
): UniversalRenderingContext => {
|
||||||
let context: WebGL2RenderingContext | WebGLRenderingContext | null = ignoreWebGL2
|
const context: WebGL2RenderingContext | WebGLRenderingContext | null = ignoreWebGL2
|
||||||
? null
|
? null
|
||||||
: canvas.getContext('webgl2');
|
: canvas.getContext('webgl2');
|
||||||
|
|
||||||
let webgl2Support = true;
|
let result = context as UniversalRenderingContext;
|
||||||
|
|
||||||
if (!context) {
|
if (context) {
|
||||||
context = canvas.getContext('webgl');
|
if (!Object.prototype.hasOwnProperty.call(context, 'isWebGL2')) {
|
||||||
webgl2Support = false;
|
result.isWebGL2 = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
result = (canvas.getContext('webgl') ||
|
||||||
|
canvas.getContext('experimental-webgl')) as UniversalRenderingContext;
|
||||||
|
|
||||||
if (!context) {
|
if (!result) {
|
||||||
context = canvas.getContext('experimental-webgl') as WebGLRenderingContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!context) {
|
|
||||||
throw new Error('Neither WebGL or WebGL2 is supported');
|
throw new Error('Neither WebGL or WebGL2 is supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
Insights.setValue('using WebGL2', webgl2Support);
|
result.isWebGL2 = false;
|
||||||
|
}
|
||||||
|
|
||||||
const result = context as UniversalRenderingContext;
|
Insights.setValue('using WebGL2', result.isWebGL2);
|
||||||
result.isWebGL2 = webgl2Support;
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue