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

some WasCleared texture handling changed

Nicolas Cannasse 8 жил өмнө
parent
commit
2e69003576

+ 0 - 3
h2d/Scene.hx

@@ -368,11 +368,8 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 		ctx.globalAlpha = alpha;
 		ctx.globalAlpha = alpha;
 		ctx.begin();
 		ctx.begin();
 		ctx.pushTarget(t);
 		ctx.pushTarget(t);
-		if( !t.flags.has(WasCleared) )
-			ctx.engine.driver.clear(new h3d.Vector(0, 0, 0, 0),1,0);
 		s.drawRec(ctx);
 		s.drawRec(ctx);
 		ctx.popTarget();
 		ctx.popTarget();
-		ctx.engine.driver.clear(new h3d.Vector(0, 0, 0, 0),1,0);
 	}
 	}
 
 
 	public function render( engine : h3d.Engine ) {
 	public function render( engine : h3d.Engine ) {

+ 2 - 3
h3d/impl/GlDriver.hx

@@ -720,7 +720,6 @@ class GlDriver extends Driver {
 			#end
 			#end
 			gl.texImage2D(GL.TEXTURE_2D, mipLevel, t.t.internalFmt, getChannels(t.t), t.t.pixelFmt, img.getImageData(0, 0, bmp.width, bmp.height));
 			gl.texImage2D(GL.TEXTURE_2D, mipLevel, t.t.internalFmt, getChannels(t.t), t.t.pixelFmt, img.getImageData(0, 0, bmp.width, bmp.height));
 			gl.bindTexture(GL.TEXTURE_2D, null);
 			gl.bindTexture(GL.TEXTURE_2D, null);
-			t.flags.set(WasCleared);
 		}
 		}
 	#end
 	#end
 	}
 	}
@@ -804,7 +803,6 @@ class GlDriver extends Driver {
 		gl.texImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, getChannels(t.t), t.t.pixelFmt, bytesToUint8Array(pixels.bytes));
 		gl.texImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, getChannels(t.t), t.t.pixelFmt, bytesToUint8Array(pixels.bytes));
 		#end
 		#end
 		gl.bindTexture(bind, null);
 		gl.bindTexture(bind, null);
-		t.flags.set(WasCleared);
 	}
 	}
 
 
 	override function uploadVertexBuffer( v : VertexBuffer, startVertex : Int, vertexCount : Int, buf : hxd.FloatBuffer, bufPos : Int ) {
 	override function uploadVertexBuffer( v : VertexBuffer, startVertex : Int, vertexCount : Int, buf : hxd.FloatBuffer, bufPos : Int ) {
@@ -980,9 +978,9 @@ class GlDriver extends Driver {
 			gl.bindTexture(bind, tex.t.t);
 			gl.bindTexture(bind, tex.t.t);
 			gl.generateMipmap(bind);
 			gl.generateMipmap(bind);
 			gl.bindTexture(bind, null);
 			gl.bindTexture(bind, null);
-			tex.flags.set(WasCleared);
 		}
 		}
 
 
+		tex.flags.set(WasCleared); // once we draw to, do not clear again
 		tex.lastFrame = frame;
 		tex.lastFrame = frame;
 		gl.bindFramebuffer(GL.FRAMEBUFFER, commonFB);
 		gl.bindFramebuffer(GL.FRAMEBUFFER, commonFB);
 		gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, tex.flags.has(Cubic) ? CUBE_FACES[face] : GL.TEXTURE_2D, tex.t.t, mipLevel);
 		gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, tex.flags.has(Cubic) ? CUBE_FACES[face] : GL.TEXTURE_2D, tex.t.t, mipLevel);
@@ -1007,6 +1005,7 @@ class GlDriver extends Driver {
 				tex.alloc();
 				tex.alloc();
 			gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0 + i, GL.TEXTURE_2D, tex.t.t, 0);
 			gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0 + i, GL.TEXTURE_2D, tex.t.t, 0);
 			tex.lastFrame = frame;
 			tex.lastFrame = frame;
+			tex.flags.set(WasCleared); // once we draw to, do not clear again
 		}
 		}
 		#if js
 		#if js
 		if( mrtExt != null )
 		if( mrtExt != null )