Skip to content

Commit ef2bc82

Browse files
committed
Fix #214 STENCIL_BITS is not displayed
1 parent 2eebad5 commit ef2bc82

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

documentation/changeLogs.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Please, find below the per release summary of the contribution added to the proj
88
* Fix [BindAttribLocation parameter display](https://github.com/BabylonJS/Spector.js/issues/220)
99
* Fix [Scissor redundant calls on clear](https://github.com/BabylonJS/Spector.js/issues/215)
1010
* Fix [Stencil command consistency](https://github.com/BabylonJS/Spector.js/issues/213)
11+
* Fix [STENCIL_BITS is not displayed in stencil state](https://github.com/BabylonJS/Spector.js/issues/214)
1112

1213
## v0.9.27
1314
* Fixed compressed textures gathered sizes.

src/backend/states/context/stencilState.ts

+30
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@ export class StencilState extends ParameterState {
4545
{ constant: WebGlConstants.STENCIL_WRITEMASK, returnType: ParameterReturnType.GlUint, changeCommands: ["stencilMask", "stencilMaskSeparate"] }];
4646
}
4747

48+
protected readFromContext(): void {
49+
super.readFromContext();
50+
51+
const gl = this.context;
52+
const target = WebGlConstants.FRAMEBUFFER.value;
53+
const attachment = WebGlConstants.STENCIL_ATTACHMENT.value;
54+
const frameBuffer = gl.getParameter(WebGlConstants.FRAMEBUFFER_BINDING.value);
55+
56+
let value = 0;
57+
if (!frameBuffer) {
58+
value = this.readParameterFromContext({ constant: WebGlConstants.STENCIL_BITS });
59+
}
60+
else {
61+
const type = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.value);
62+
if (type !== WebGlConstants.NONE.value) {
63+
if (this.contextVersion > 1) {
64+
value = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE.value);
65+
}
66+
else {
67+
const storage = this.context.getFramebufferAttachmentParameter(target, attachment, WebGlConstants.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME.value);
68+
if (storage === WebGlConstants.RENDERBUFFER.value) {
69+
value = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_STENCIL_SIZE);
70+
}
71+
}
72+
}
73+
}
74+
75+
this.currentState[WebGlConstants.STENCIL_BITS.name] = "" + value;
76+
}
77+
4878
protected isValidChangeCommand(command: ICommandCapture, stateName: string): boolean {
4979
if (command.name === "enable" || command.name === "disable") {
5080
return command.commandArguments[0] === WebGlConstants.STENCIL_TEST.value;

0 commit comments

Comments
 (0)