mirror of
https://github.com/nasa/openmct.git
synced 2025-05-06 02:28:21 +00:00
[Plot] Fall back from WebGL on context loss
When a WebGL context is loss, fall back to displaying plots using regular canvas 2d API. WTD-475.
This commit is contained in:
parent
dac44623ee
commit
b6fdf4d6ab
@ -155,6 +155,7 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Switch from WebGL to plain 2D if context is lost
|
||||||
function fallbackFromWebGL() {
|
function fallbackFromWebGL() {
|
||||||
element.html(TEMPLATE);
|
element.html(TEMPLATE);
|
||||||
canvas = element.find("canvas")[0];
|
canvas = element.find("canvas")[0];
|
||||||
@ -173,6 +174,11 @@ define(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WebGL is a bit of a special case; it may work, then fail
|
||||||
|
// later for various reasons, so we need to listen for this
|
||||||
|
// and fall back to plain canvas drawing when it occurs.
|
||||||
|
canvas.addEventListener("webglcontextlost", fallbackFromWebGL);
|
||||||
|
|
||||||
// Check for resize, on a timer
|
// Check for resize, on a timer
|
||||||
activeInterval = $interval(drawIfResized, 1000);
|
activeInterval = $interval(drawIfResized, 1000);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user