Skip to content

Commit

Permalink
Merge pull request #232 from TiborUdvari/fix/background
Browse files Browse the repository at this point in the history
fix: background function override
  • Loading branch information
TiborUdvari authored Sep 12, 2024
2 parents a92573a + 63e0318 commit 48b6988
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/p5xr/core/p5overrides.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import { lineVert, lineFrag } from '../shaders/lineShader';
import compareVersions from '../utilities/versionComparator';

/**
* Override default p5 background to take viewport into account
* Important for stereo rendering
* @ignore
*/
const originalBackground = p5.prototype.background;
p5.prototype.background = function (...args) {
const gl = this._renderer.GL;
const viewport = this._renderer._viewport;
gl.scissor(viewport[0], viewport[1], viewport[2], viewport[3]);
gl.enable(gl.SCISSOR_TEST);
originalBackground.call(this, ...args);
gl.disable(gl.SCISSOR_TEST);
return this;
};

/**
* Override default p5 line shader to avoid issue in v1.10.0
* https://github.com/processing/p5.js/issues/7200
Expand Down

0 comments on commit 48b6988

Please sign in to comment.