Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] reset internal cached state for face culling when the device is restored #6155

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/platform/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,13 @@ class WebglGraphicsDevice extends GraphicsDevice {

this._contextLostHandler = (event) => {
event.preventDefault();
this.contextLost = true;
this.loseContext();
Debug.log('pc.GraphicsDevice: WebGL context lost.');
this.fire('devicelost');
};

this._contextRestoredHandler = () => {
Debug.log('pc.GraphicsDevice: WebGL context restored.');
this.contextLost = false;
this.restoreContext();
this.fire('devicerestored');
};
Expand Down Expand Up @@ -1229,6 +1227,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
gl.blendColor(0, 0, 0, 0);

gl.enable(gl.CULL_FACE);

this.cullFace = gl.BACK;
gl.cullFace(gl.BACK);

// default depth state
Expand Down Expand Up @@ -1321,6 +1321,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
*/
loseContext() {

this.contextLost = true;

// force the backbuffer to be recreated on restore
this.backBufferSize.set(-1, -1);

Expand Down Expand Up @@ -1355,6 +1357,9 @@ class WebglGraphicsDevice extends GraphicsDevice {
* @ignore
*/
restoreContext() {

this.contextLost = false;

this.initializeExtensions();
this.initializeCapabilities();
this.initializeRenderState();
Expand Down