소스 검색

save/restore backgroundColor to prevent flicker (close #661)

Nicolas Cannasse 5 년 전
부모
커밋
3160b66ab4
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      h2d/Scene.hx

+ 3 - 0
h2d/Scene.hx

@@ -648,6 +648,8 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 		if( !t.flags.has(Target) ) throw "Can only draw to texture created with Target flag";
 		if( !t.flags.has(Target) ) throw "Can only draw to texture created with Target flag";
 		var needClear = !t.flags.has(WasCleared);
 		var needClear = !t.flags.has(WasCleared);
 		ctx.engine = h3d.Engine.getCurrent();
 		ctx.engine = h3d.Engine.getCurrent();
+		var oldBG = ctx.engine.backgroundColor;
+		ctx.engine.backgroundColor = null; // prevent clear bg
 		ctx.engine.begin();
 		ctx.engine.begin();
 		ctx.globalAlpha = alpha;
 		ctx.globalAlpha = alpha;
 		ctx.begin();
 		ctx.begin();
@@ -656,6 +658,7 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 			ctx.engine.clear(0);
 			ctx.engine.clear(0);
 		s.drawRec(ctx);
 		s.drawRec(ctx);
 		ctx.popTarget();
 		ctx.popTarget();
+		ctx.engine.backgroundColor = oldBG;
 	}
 	}
 
 
 	/**
 	/**