mirror of
https://github.com/nasa/openmct.git
synced 2025-02-08 12:00:38 +00:00
fix: add null check for losing webgl context
This commit is contained in:
parent
97cb783c4b
commit
3cc0ecd900
@ -154,15 +154,21 @@ DrawWebGL.prototype.initContext = function () {
|
||||
DrawWebGL.prototype.destroy = function () {
|
||||
// Lose the context and delete all associated resources
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#lose_contexts_eagerly
|
||||
this.gl.getExtension('WEBGL_lose_context').loseContext();
|
||||
if (this.gl.getSupportedExtensions().includes('WEBGL_lose_context')) {
|
||||
this.gl.getExtension('WEBGL_lose_context').loseContext();
|
||||
}
|
||||
this.gl.deleteBuffer(this.buffer);
|
||||
this.buffer = undefined;
|
||||
|
||||
this.gl.deleteProgram(this.program);
|
||||
this.program = undefined;
|
||||
|
||||
this.gl.deleteShader(this.vertexShader);
|
||||
this.vertexShader = undefined;
|
||||
|
||||
this.gl.deleteShader(this.fragmentShader);
|
||||
this.fragmentShader = undefined;
|
||||
|
||||
this.gl = undefined;
|
||||
|
||||
this.stopListening();
|
||||
|
Loading…
x
Reference in New Issue
Block a user