Эх сурвалжийг харах

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

Mario Zechner 2 жил өмнө
parent
commit
83a8e5d66b

+ 1 - 1
CHANGELOG.md

@@ -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

+ 9 - 3
spine-ts/spine-webgl/src/PolygonBatcher.ts

@@ -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 () {