Sfoglia il codice sorgente

don't call engine.begin() if we're already into render()

Nicolas Cannasse 4 anni fa
parent
commit
7396090e34
2 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 1 1
      h2d/Scene.hx
  2. 3 0
      h3d/Engine.hx

+ 1 - 1
h2d/Scene.hx

@@ -726,7 +726,7 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 		ctx.engine = h3d.Engine.getCurrent();
 		var oldBG = ctx.engine.backgroundColor;
 		ctx.engine.backgroundColor = null; // prevent clear bg
-		ctx.engine.begin();
+		if( @:privateAccess !ctx.engine.inRender ) ctx.begin(); // don't reset current tex stack
 		ctx.globalAlpha = alpha;
 		ctx.begin();
 		ctx.pushTargets(texs);

+ 3 - 0
h3d/Engine.hx

@@ -50,6 +50,7 @@ class Engine {
 	var needFlushTarget : Bool;
 	var nullTexture : h3d.mat.Texture;
 	var textureColorCache = new Map<Int,h3d.mat.Texture>();
+	var inRender = false;
 	public var ready(default,null) = false;
 	@:allow(hxd.res) var resCache = new Map<{},Dynamic>();
 
@@ -286,6 +287,7 @@ class Engine {
 		if( driver.isDisposed() )
 			return false;
 		// init
+		inRender = true;
 		drawTriangles = 0;
 		shaderSwitches = 0;
 		drawCalls = 0;
@@ -304,6 +306,7 @@ class Engine {
 	}
 
 	public function end() {
+		inRender = false;
 		driver.end();
 	}