ncannasse 11 år sedan
förälder
incheckning
be6e7fbf1d
2 ändrade filer med 21 tillägg och 2 borttagningar
  1. 16 1
      h3d/impl/Stage3dDriver.hx
  2. 5 1
      h3d/mat/Texture.hx

+ 16 - 1
h3d/impl/Stage3dDriver.hx

@@ -401,9 +401,24 @@ class Stage3dDriver extends Driver {
 			curBuffer = null;
 		}
 	}
+
+	function debugDraw( ibuf : IndexBuffer, startIndex : Int, ntriangles : Int ) {
+		try {
+			ctx.drawTriangles(ibuf, startIndex, ntriangles);
+		} catch( e : flash.errors.Error ) {
+			// this error should not happen, but sometime does in debug mode (?)
+			if( e.errorID != 3605 )
+				throw e;
+		}
+	}
 	
 	override function draw( ibuf : IndexBuffer, startIndex : Int, ntriangles : Int ) {
-		if( enableDraw ) ctx.drawTriangles(ibuf, startIndex, ntriangles);
+		if( enableDraw ) {
+			if( ctx.enableErrorChecking )
+				debugDraw(ibuf, startIndex, ntriangles);
+			else
+				ctx.drawTriangles(ibuf, startIndex, ntriangles);
+		}
 	}
 
 	override function setRenderZone( x : Int, y : Int, width : Int, height : Int ) {

+ 5 - 1
h3d/mat/Texture.hx

@@ -143,8 +143,12 @@ class Texture {
 	}
 
 	public function dispose() {
-		if( t != null )
+		if( t != null ) {
 			mem.deleteTexture(this);
+			#if debug
+			this.allocPos.customParams = ["#DISPOSED"];
+			#end
+		}
 	}
 	
 	public static function fromBitmap( bmp : hxd.BitmapData, ?allocPos : h3d.impl.AllocPos ) {