From 8581c7924e83c5e455d25d47e2a288bfe404c0a7 Mon Sep 17 00:00:00 2001 From: shrekshao Date: Wed, 27 Jul 2016 15:50:49 -0400 Subject: [PATCH] some fix for stencilbuffer --- dev-scripts.json | 2 ++ src/core/display/chunks/stencilBufferChunk.js | 2 ++ src/core/scene/stencilBuffer.js | 10 +++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dev-scripts.json b/dev-scripts.json index 8e5148b0..aefc5cb5 100644 --- a/dev-scripts.json +++ b/dev-scripts.json @@ -52,6 +52,7 @@ "src/core/scene/name.js", "src/core/scene/renderer.js", "src/core/scene/depthBuffer.js", + "src/core/scene/stencilBuffer.js", "src/core/scene/colorBuffer.js", "src/core/scene/view.js", "src/core/scene/scene.js", @@ -95,6 +96,7 @@ "src/core/display/chunks/rendererChunk.js", "src/core/display/chunks/regionMapChunk.js", "src/core/display/chunks/depthBufferChunk.js", + "src/core/display/chunks/stencilBufferChunk.js", "src/core/display/chunks/colorBufferChunk.js", "src/core/display/chunks/viewChunk.js", "src/core/display/chunks/shaderChunk.js", diff --git a/src/core/display/chunks/stencilBufferChunk.js b/src/core/display/chunks/stencilBufferChunk.js index 376565c2..d1b476f9 100644 --- a/src/core/display/chunks/stencilBufferChunk.js +++ b/src/core/display/chunks/stencilBufferChunk.js @@ -37,6 +37,8 @@ SceneJS_ChunkFactory.createChunkType({ frameCtx.stencilFunc = stencilFunc; } + var stencilOp = this.core.stencilOp; + if (frameCtx.stencilOp != stencilOp) { gl.stencilOp(stencilOp.sfail, stencilOp.dpfail, stencilOp.dppass); frameCtx.stencilOp = stencilOp; diff --git a/src/core/scene/stencilBuffer.js b/src/core/scene/stencilBuffer.js index 6c8b7ad0..52e1bc4f 100644 --- a/src/core/scene/stencilBuffer.js +++ b/src/core/scene/stencilBuffer.js @@ -26,7 +26,7 @@ var defaultCore = { type: "stencilBuffer", stateId: SceneJS._baseStateId++, - enabled: true, + enabled: false, clearStencil: 1, stencilFunc: {func: null, ref: 1, mask: 0xff}, // Lazy init stencilFunc when we can get a context stencilOp: {sfail: null, dpfail: null, dppass: null}, @@ -40,12 +40,12 @@ SceneJS_events.addListener( SceneJS_events.SCENE_COMPILING, function (params) { - if (defaultCore.stencilFunc === null) { // Lazy-init stencilFunc now we can get a context + if (defaultCore.stencilFunc.func === null) { // Lazy-init stencilFunc now we can get a context defaultCore.stencilFunc.func = params.engine.canvas.gl.ALWAYS; - defaultCore.stencilFunc.sfail = params.engine.canvas.gl.KEEP; - defaultCore.stencilFunc.dpfail = params.engine.canvas.gl.KEEP; - defaultCore.stencilFunc.dppass = params.engine.canvas.gl.KEEP; + defaultCore.stencilOp.sfail = params.engine.canvas.gl.KEEP; + defaultCore.stencilOp.dpfail = params.engine.canvas.gl.KEEP; + defaultCore.stencilOp.dppass = params.engine.canvas.gl.KEEP; } params.engine.display.stencilBuffer = defaultCore; stackLen = 0;