Skip to content

Commit

Permalink
Fix #213 Stencil command consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
sebavan committed Jan 18, 2022
1 parent 379e5f0 commit 9151e0f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/backend/commands/stencilFunc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { BaseCommand } from "./baseCommand";
import { WebGlConstants } from "../types/webglConstants";

export class StencilFunc extends BaseCommand {
public static readonly commandName = "stencilFunc";

protected get spiedCommandName(): string {
return StencilFunc.commandName;
}

protected stringifyArgs(args: IArguments): string[] {
const stringified = [];
stringified.push(WebGlConstants.stringifyWebGlConstant(args[0], "stencilFunc"));
stringified.push(`${args[1].toFixed(0)} (0b${(args[1] >>> 0).toString(2)})`);
stringified.push(`${args[2].toFixed(0)} (0b${(args[2] >>> 0).toString(2)})`);

return stringified;
}
}
16 changes: 16 additions & 0 deletions src/backend/commands/stencilMask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BaseCommand } from "./baseCommand";

export class StencilMask extends BaseCommand {
public static readonly commandName = "stencilMask";

protected get spiedCommandName(): string {
return StencilMask.commandName;
}

protected stringifyArgs(args: IArguments): string[] {
const stringified = [];
stringified.push(`${args[0].toFixed(0)} (0b${(args[0] >>> 0).toString(2)})`);

return stringified;
}
}
18 changes: 18 additions & 0 deletions src/backend/commands/stencilMaskSeparate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { BaseCommand } from "./baseCommand";
import { WebGlConstants } from "../types/webglConstants";

export class StencilMaskSeparate extends BaseCommand {
public static readonly commandName = "stencilMaskSeparate";

protected get spiedCommandName(): string {
return StencilMaskSeparate.commandName;
}

protected stringifyArgs(args: IArguments): string[] {
const stringified = [];
stringified.push(WebGlConstants.stringifyWebGlConstant(args[0], "stencilMaskSeparate"));
stringified.push(`${args[1].toFixed(0)} (0b${(args[1] >>> 0).toString(2)})`);

return stringified;
}
}
6 changes: 6 additions & 0 deletions src/backend/spies/commandSpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import { GetParameter } from "../commands/getParameter";
import { GetShaderPrecisionFormat } from "../commands/getShaderPrecisionFormat";
import { GetTransformFeedbackVarying } from "../commands/getTransformFeedbackVarying";
import { Scissor } from "../commands/scissor";
import { StencilMask } from "../commands/stencilMask";
import { StencilMaskSeparate } from "../commands/stencilMaskSeparate";
import { StencilFunc } from "../commands/stencilFunc";
import { StencilFuncSeparate } from "../commands/stencilFuncSeparate";
import { VertexAttribPointer } from "../commands/vertexAttribPointer";
import { Viewport } from "../commands/viewport";
Expand Down Expand Up @@ -142,6 +145,9 @@ export class CommandSpy {
[GetShaderPrecisionFormat.commandName]: (options: IContextInformation) => new GetShaderPrecisionFormat(options),
[GetTransformFeedbackVarying.commandName]: (options: IContextInformation) => new GetTransformFeedbackVarying(options),
[Scissor.commandName]: (options: IContextInformation) => new Scissor(options),
[StencilMask.commandName]: (options: IContextInformation) => new StencilMask(options),
[StencilMaskSeparate.commandName]: (options: IContextInformation) => new StencilMaskSeparate(options),
[StencilFunc.commandName]: (options: IContextInformation) => new StencilFunc(options),
[StencilFuncSeparate.commandName]: (options: IContextInformation) => new StencilFuncSeparate(options),
[VertexAttribPointer.commandName]: (options: IContextInformation) => new VertexAttribPointer(options),
[Viewport.commandName]: (options: IContextInformation) => new Viewport(options),
Expand Down

0 comments on commit 9151e0f

Please sign in to comment.