Răsfoiți Sursa

IsRectangle -> IsNPOT

Nicolas Cannasse 11 ani în urmă
părinte
comite
5f19928272
3 a modificat fișierele cu 22 adăugiri și 22 ștergeri
  1. 3 3
      h3d/impl/Stage3dDriver.hx
  2. 1 1
      h3d/mat/Data.hx
  3. 18 18
      h3d/mat/Texture.hx

+ 3 - 3
h3d/impl/Stage3dDriver.hx

@@ -203,7 +203,7 @@ class Stage3dDriver extends Driver {
 		if( t.flags.has(TargetDepth) )
 			throw "Unsupported texture flag";
 		try {
-			if( t.flags.has(IsRectangle) ) {
+			if( t.flags.has(IsNPOT) ) {
 				if( t.flags.has(Cubic) || t.flags.has(MipMapped) )
 					throw "Not power of two texture is not supported with these flags";
 				#if !flash11_8
@@ -226,7 +226,7 @@ class Stage3dDriver extends Driver {
 		if( t.flags.has(Cubic) ) {
 			var t = flash.Lib.as(t.t, flash.display3D.textures.CubeTexture);
 			t.uploadFromBitmapData(bmp.toNative(), side, mipLevel);
-		} else if( t.flags.has(IsRectangle) ) {
+		} else if( t.flags.has(IsNPOT) ) {
 			#if flash11_8
 			var t = flash.Lib.as(t.t, flash.display3D.textures.RectangleTexture);
 			t.uploadFromBitmapData(bmp.toNative());
@@ -243,7 +243,7 @@ class Stage3dDriver extends Driver {
 		if( t.flags.has(Cubic) ) {
 			var t = flash.Lib.as(t.t, flash.display3D.textures.CubeTexture);
 			t.uploadFromByteArray(data, 0, side, mipLevel);
-		} else if( t.flags.has(IsRectangle) ) {
+		} else if( t.flags.has(IsNPOT) ) {
 			#if flash11_8
 			var t = flash.Lib.as(t.t, flash.display3D.textures.RectangleTexture);
 			t.uploadFromByteArray(data, 0);

+ 1 - 1
h3d/mat/Data.hx

@@ -88,7 +88,7 @@ enum TextureFlags {
 	/**
 		This is a not power of two texture. Automatically set when having width or height being not power of two.
 	**/
-	IsRectangle;
+	IsNPOT;
 	/**
 		Don't initialy allocate the texture memory.
 	**/

+ 18 - 18
h3d/mat/Texture.hx

@@ -5,7 +5,7 @@ import h3d.mat.Data;
 class Texture {
 
 	static var UID = 0;
-	
+
 	var t : h3d.impl.Driver.Texture;
 	var mem : h3d.impl.MemoryManager;
 	#if debug
@@ -28,7 +28,7 @@ class Texture {
 		it's been free because of lack of memory.
 	**/
 	public var realloc : Void -> Void;
-	
+
 	public function new(w, h, ?flags : Array<TextureFlags>, ?allocPos : h3d.impl.AllocPos ) {
 		var engine = h3d.Engine.getCurrent();
 		this.mem = engine.mem;
@@ -42,8 +42,8 @@ class Texture {
 		while( tw < w ) tw <<= 1;
 		while( th < h) th <<= 1;
 		if( tw != w || th != h )
-			this.flags.set(IsRectangle);
-			
+			this.flags.set(IsNPOT);
+
 		// make the texture disposable if we're out of memory
 		// this can be disabled after allocation by reseting realloc
 		if( this.flags.has(Target) ) realloc = function() { };
@@ -59,16 +59,16 @@ class Texture {
 		#end
 		alloc();
 	}
-	
+
 	public function alloc() {
 		if( t == null )
 			mem.allocTexture(this);
 	}
-	
+
 	function toString() {
 		return name+" "+width+"x"+height;
 	}
-	
+
 	public function setName(n) {
 		name = n;
 	}
@@ -84,13 +84,13 @@ class Texture {
 		bits = (bits & ~(3 << 3)) | (Type.enumIndex(f) << 3);
 		return filter = f;
 	}
-	
+
 	function set_wrap(w:Wrap) {
 		bits |= 0x80000;
 		bits = (bits & ~(3 << 6)) | (Type.enumIndex(w) << 6);
 		return wrap = w;
 	}
-	
+
 	inline function hasDefaultFlags() {
 		return bits & 0x80000 == 0;
 	}
@@ -98,21 +98,21 @@ class Texture {
 	public inline function isDisposed() {
 		return t == null && realloc == null;
 	}
-	
+
 	public function resize(width, height) {
 		dispose();
-		
+
 		var tw = 1, th = 1;
 		while( tw < width ) tw <<= 1;
 		while( th < height ) th <<= 1;
 		if( tw != width || th != height )
-			this.flags.set(IsRectangle);
+			this.flags.set(IsNPOT);
 		else
-			this.flags.unset(IsRectangle);
+			this.flags.unset(IsNPOT);
 
 		this.width = width;
 		this.height = height;
-		
+
 		if( !flags.has(NoAlloc) )
 			alloc();
 	}
@@ -131,7 +131,7 @@ class Texture {
 		uploadPixels(p);
 		p.dispose();
 	}
-	
+
 	public function uploadBitmap( bmp : hxd.BitmapData, mipLevel = 0, side = 0 ) {
 		alloc();
 		mem.driver.uploadTextureBitmap(this, bmp, mipLevel, side);
@@ -150,19 +150,19 @@ class Texture {
 			#end
 		}
 	}
-	
+
 	public static function fromBitmap( bmp : hxd.BitmapData, ?allocPos : h3d.impl.AllocPos ) {
 		var t = new Texture(bmp.width, bmp.height, allocPos);
 		t.uploadBitmap(bmp);
 		return t;
 	}
-	
+
 	public static function fromPixels( pixels : hxd.Pixels, ?allocPos : h3d.impl.AllocPos ) {
 		var t = new Texture(pixels.width, pixels.height, allocPos);
 		t.uploadPixels(pixels);
 		return t;
 	}
-	
+
 	static var COLOR_CACHE = new Map<Int,h3d.mat.Texture>();
 	/**
 		Creates a 1x1 texture using the ARGB color passed as parameter.