Explorar o código

try/catch allocIndexes

Nicolas Cannasse %!s(int64=10) %!d(string=hai) anos
pai
achega
8ebadc8ab3
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      h3d/impl/Stage3dDriver.hx

+ 8 - 1
h3d/impl/Stage3dDriver.hx

@@ -218,7 +218,14 @@ class Stage3dDriver extends Driver {
 	}
 
 	override function allocIndexes( count : Int ) : IndexBuffer {
-		return ctx.createIndexBuffer(count);
+		try {
+			return ctx.createIndexBuffer(count);
+		} catch( e : flash.errors.Error ) {
+			// too many resources / out of memory
+			if( e.errorID == 3691 )
+				return null;
+			throw e;
+		}
 	}
 
 	function getMipLevels( t : h3d.mat.Texture ) {