Skip to content

Commit

Permalink
some fix for stencilbuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
shrekshao committed Jul 27, 2016
1 parent 2c9ad57 commit 8581c79
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dev-scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/core/display/chunks/stencilBufferChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/core/scene/stencilBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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;
Expand Down

0 comments on commit 8581c79

Please sign in to comment.