mirror of
https://github.com/nasa/openmct.git
synced 2025-02-22 18:12:57 +00:00
Eagerly lose WebGL context on DrawWebGL.destroy()
(#7080)
* test default for preserveDrawingBuffer * fix: delete WebGL resources on destroy * fix: eagerly lose WebGL contexts on destroy - Recommended by Mozilla's [WebGL best practices]-(https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#lose_contexts_eagerly). Co-authored-by: Jesse Mazzella <jesse.d.mazzella@nasa.gov> Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>
This commit is contained in:
parent
d973140906
commit
d53d8d562e
@ -152,9 +152,22 @@ DrawWebGL.prototype.initContext = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
DrawWebGL.prototype.destroy = 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();
|
||||||
|
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();
|
||||||
this.canvas = undefined;
|
this.canvas = undefined;
|
||||||
this.overlay = undefined;
|
this.overlay = undefined;
|
||||||
this.stopListening();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert from logical to physical x coordinates
|
// Convert from logical to physical x coordinates
|
||||||
|
Loading…
x
Reference in New Issue
Block a user