Skip to content

Commit 5d7a1bb

Browse files
authored
Merge branch 'TurboWarp:develop' into develop
2 parents 957bf6c + 7d0df87 commit 5d7a1bb

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/RenderConstants.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ module.exports = {
3232
* @type {object}
3333
* @property {Array<int>} newSize - the new size of the renderer
3434
*/
35-
NativeSizeChanged: 'NativeSizeChanged'
35+
NativeSizeChanged: 'NativeSizeChanged',
36+
37+
/**
38+
* Event emitted when the WebGL context is lost.
39+
*
40+
* @event RenderWebGL#event:ContextLost
41+
*/
42+
ContextLost: 'ContextLost'
3643
}
3744
};

‎src/RenderWebGL.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ class RenderWebGL extends EventEmitter {
292292

293293
this.on(RenderConstants.Events.NativeSizeChanged, this.onNativeSizeChanged);
294294

295+
gl.canvas.addEventListener('webglcontextlost', () => {
296+
this.emit(RenderConstants.Events.ContextLost);
297+
});
298+
295299
this.setBackgroundColor(1, 1, 1);
296300
this.setStageSize(xLeft || -240, xRight || 240, yBottom || -180, yTop || 180);
297301
this.resize(this._nativeSize[0], this._nativeSize[1]);

0 commit comments

Comments
 (0)