[ts][player][webgl] Closes #2227, instead of disabling culling automatically, make it configurable via PolygonBatcher.disableCulling. Off by default.

This commit is contained in:
Mario Zechner 2023-01-26 15:49:02 +01:00
parent 0042015e7c
commit 83a8e5d66b
2 changed files with 10 additions and 4 deletions

View File

@ -143,7 +143,7 @@
* `VertexEffect` has been removed.
### WebGL backend
* `PolygonBatcher.start()` now disables culling and restores the previous state on `PolygonBatcher.end()`.
* `PolygonBatcher` can now disable culling automatically if the static variable `PolygonBatcher.disableCulling` is set to true.
* Added `SpineCanvas`, a simpler way to render a scene via spine-webgl. See `spine-ts/spine-webgl/examples/barebones.html` and `spine-ts/spine-webgl/examples/mix-and-match.html`.
### Canvas backend

View File

@ -34,6 +34,8 @@ import { Shader } from "./Shader";
import { ManagedWebGLRenderingContext } from "./WebGL";
export class PolygonBatcher implements Disposable {
public static disableCulling = false;
private context: ManagedWebGLRenderingContext;
private drawCalls = 0;
private static globalDrawCalls = 0;
@ -72,8 +74,10 @@ export class PolygonBatcher implements Disposable {
gl.enable(gl.BLEND);
gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
if (this.cullWasEnabled) gl.disable(gl.CULL_FACE);
if (PolygonBatcher.disableCulling) {
this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
if (this.cullWasEnabled) gl.disable(gl.CULL_FACE);
}
}
setBlendMode (srcColorBlend: number, srcAlphaBlend: number, dstBlend: number) {
@ -133,7 +137,9 @@ export class PolygonBatcher implements Disposable {
let gl = this.context.gl;
gl.disable(gl.BLEND);
if (this.cullWasEnabled) gl.enable(gl.CULL_FACE);
if (PolygonBatcher.disableCulling) {
if(this.cullWasEnabled) gl.enable(gl.CULL_FACE);
}
}
getDrawCalls () {