Skip to content

Commit

Permalink
fix(patch): state reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sakitam-fdd committed Mar 25, 2023
1 parent 5360122 commit 7adafcc
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/core/State.ts
Expand Up @@ -627,11 +627,14 @@ export default class State extends Base {
*/
setStencilFunc(cmp: GLenum, ref: GLenum, mask: GLenum, face?: GLenum) {
if (
this.#state.stencil?.func?.cmp !== cmp ||
this.#state.stencil?.func?.ref !== ref ||
this.#state.stencil?.func?.mask !== mask
this.#state?.stencil?.func?.cmp !== cmp ||
this.#state?.stencil?.func?.ref !== ref ||
this.#state?.stencil?.func?.mask !== mask
) {
if (!this.#state.stencil?.func) {
if (!this.#state?.stencil) {
this.#state.stencil = {} as StateOptions['stencil'];
}
if (!this.#state?.stencil?.func) {
this.#state.stencil.func = {} as StateOptions['stencil']['func'];
}
this.#state.stencil.func = {
Expand All @@ -657,6 +660,10 @@ export default class State extends Base {
setStencilOp(fail, zFail, zPass, face?: GLenum) {
const flag = false;

if (!this.#state?.stencil) {
this.#state.stencil = {} as StateOptions['stencil'];
}

if (!face || face === this.gl.FRONT_AND_BACK) {
return (
this.#state.stencil?.opFront?.fail !== fail ||
Expand Down Expand Up @@ -843,6 +850,11 @@ export default class State extends Base {
currentProgramId: -1,
clearAlpha: 1,
clearColor: new Color(0),
stencil: {
func: {},
opFront: {},
opBack: {},
},
} as unknown as StateOptions);
} else {
keys
Expand Down

0 comments on commit 7adafcc

Please sign in to comment.