Skip to content

Commit

Permalink
Invoke onError when GL context is lost (visgl#5731)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored May 6, 2021
1 parent dd9945d commit ad10ace
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions modules/core/src/lib/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,18 @@ export default class Deck {
}

_createAnimationLoop(props) {
const {width, height, gl, glOptions, debug, useDevicePixels, autoResizeDrawingBuffer} = props;
const {
width,
height,
gl,
glOptions,
debug,
onError,
onBeforeRender,
onAfterRender,
useDevicePixels,
autoResizeDrawingBuffer
} = props;

return new AnimationLoop({
width,
Expand All @@ -491,12 +502,19 @@ export default class Deck {
autoResizeDrawingBuffer,
autoResizeViewport: false,
gl,
onCreateContext: opts => createGLContext({...glOptions, ...opts, canvas: this.canvas, debug}),
onCreateContext: opts =>
createGLContext({
...glOptions,
...opts,
canvas: this.canvas,
debug,
onContextLost: _ => onError?.(new Error(`WebGL context is lost`))
}),
onInitialize: context => this._setGLContext(context.gl),
onRender: this._onRenderFrame.bind(this),
onBeforeRender: props.onBeforeRender,
onAfterRender: props.onAfterRender,
onError: props.onError
onBeforeRender,
onAfterRender,
onError
});
}

Expand Down

0 comments on commit ad10ace

Please sign in to comment.