浏览代码

fixes for cube texture : clear() all faces, default cube texture correctly selected

ncannasse 7 年之前
父节点
当前提交
05341d33e1
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 7 3
      h3d/impl/GlDriver.hx
  2. 2 1
      h3d/mat/Texture.hx

+ 7 - 3
h3d/impl/GlDriver.hx

@@ -371,9 +371,14 @@ class GlDriver extends Driver {
 			var tcount = s.textures.length;
 			for( i in 0...s.textures.length + s.cubeTextures.length ) {
 				var t = buf.tex[i];
+				var isCube = i >= tcount;
 				if( t == null || t.isDisposed() ) {
-					var color = h3d.mat.Defaults.loadingTextureColor;
-					t = h3d.mat.Texture.fromColor(color,(color>>>24)/255);
+					if( isCube ) {
+						t = h3d.mat.Texture.defaultCubeTexture();
+					} else {
+						var color = h3d.mat.Defaults.loadingTextureColor;
+						t = h3d.mat.Texture.fromColor(color, (color >>> 24) / 255);
+					}
 				}
 				if( t != null && t.t == null && t.realloc != null ) {
 					t.alloc();
@@ -381,7 +386,6 @@ class GlDriver extends Driver {
 				}
 				t.lastFrame = frame;
 
-				var isCube = i >= tcount;
 				var pt = isCube ? s.cubeTextures[i - tcount] : s.textures[i];
 				if( pt == null ) continue;
 				if( boundTextures[i] == t.t ) continue;

+ 2 - 1
h3d/mat/Texture.hx

@@ -201,7 +201,8 @@ class Texture {
 			p.bytes.set(k++,a);
 		}
 		if( nativeFlip ) p.flags.set(FlipY);
-		uploadPixels(p);
+		for( i in 0...(flags.has(Cube) ? 6 : 1) )
+			uploadPixels(p, 0, i);
 		p.dispose();
 	}