Browse Source

Revert "opengl: fix uploadTexturePixels for texture arrays"

This reverts commit 60ebd027e142ff01745e7675069ad62b41f4cec9.
trethaller 4 years ago
parent
commit
fea1b9dbc4
1 changed files with 6 additions and 21 deletions
  1. 6 21
      h3d/impl/GlDriver.hx

+ 6 - 21
h3d/impl/GlDriver.hx

@@ -20,8 +20,6 @@ private extern class GL2 extends js.html.webgl.GL {
 	function framebufferTextureLayer( target : Int, attach : Int, t : js.html.webgl.Texture, level : Int, layer : Int ) : Void;
 	function texImage3D(target : Int, level : Int, internalformat : Int, width : Int, height : Int, depth : Int, border : Int, format : Int, type : Int, source : Dynamic) : Void;
 	function compressedTexImage3D(target : Int, level : Int, internalformat : Int, width : Int, height : Int, depth : Int, border : Int, source : Dynamic) : Void;
-	function texSubImage3D( target : Int, level : Int, xoffset : Int, yoffset : Int, zoffset : Int, width : Int, height : Int, depth : Int, format : Int, type : Int, image : Dynamic ) : Void;
-	function compressedTexSubImage3D( target : Int, level : Int, xoffset : Int, yoffset : Int, zoffset : Int, width : Int, height : Int, depth : Int, format : Int, image : Dynamic ) : Void;
 	static inline var RGBA16F = 0x881A;
 	static inline var RGBA32F = 0x8814;
 	static inline var RED      = 0x1903;
@@ -1183,8 +1181,8 @@ class GlDriver extends Driver {
 
 	override function uploadTexturePixels( t : h3d.mat.Texture, pixels : hxd.Pixels, mipLevel : Int, side : Int ) {
 		var cubic = t.flags.has(Cube);
-		var face = cubic ? CUBE_FACES[side] : t.flags.has(IsArray) ? GL2.TEXTURE_2D_ARRAY : GL.TEXTURE_2D;
 		var bind = getBindType(t);
+		var face = cubic ? CUBE_FACES[side] : GL.TEXTURE_2D;
 		gl.bindTexture(bind, t.t.t);
 		pixels.convert(t.format);
 		pixels.setFlip(false);
@@ -1196,13 +1194,13 @@ class GlDriver extends Driver {
 			throw "Compressed textures require hlsdl 1.10+";
 			#else
 			if( t.flags.has(IsArray) )
-				gl.compressedTexSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, t.t.internalFmt, dataLen, stream);
+				gl.compressedTexImage3D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, side, 0, dataLen, stream);
 			else
 				gl.compressedTexImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, dataLen, stream);
 			#end
 		} else {
 			if( t.flags.has(IsArray) )
-				gl.texSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, getChannels(t.t), t.t.pixelFmt, stream);
+				gl.texImage3D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, side, 0, getChannels(t.t), t.t.pixelFmt, stream);
 			else
 				gl.texImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, getChannels(t.t), t.t.pixelFmt, stream);
 		}
@@ -1215,6 +1213,7 @@ class GlDriver extends Driver {
 			pixels = pixels.clone();
 		}
 		#end
+		if( t.flags.has(IsArray) ) throw "TODO:texImage3D";
 		var buffer : ArrayBufferView = switch( t.format ) {
 		case RGBA32F, R32F, RG32F, RGB32F: new Float32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen>>2);
 		case RGBA16F, R16F, RG16F, RGB16F: new Uint16Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen>>1);
@@ -1223,12 +1222,12 @@ class GlDriver extends Driver {
 		}
 		if( t.format.match(S3TC(_)) ) {
 			if( t.flags.has(IsArray) )
-				gl.compressedTexSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, t.t.internalFmt, buffer);
+				gl.compressedTexImage3D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, side, 0, buffer);
 			else
 				gl.compressedTexImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, buffer);
 		} else {
 			if( t.flags.has(IsArray) )
-				gl.texSubImage3D(face, mipLevel, 0, 0, side, pixels.width, pixels.height, 1, getChannels(t.t), t.t.pixelFmt, buffer);
+				gl.texImage3D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, side, 0, getChannels(t.t), t.t.pixelFmt, buffer);
 			else
 				gl.texImage2D(face, mipLevel, t.t.internalFmt, pixels.width, pixels.height, 0, getChannels(t.t), t.t.pixelFmt, buffer);
 		}
@@ -1778,20 +1777,6 @@ class GlDriver extends Driver {
 		return GL.queryResult(q.q);
 	}
 
-	inline function debugCheckError() {
-		if(!debug) return;
-		var err = gl.getError();
-		if(err != GL.NO_ERROR) {
-			switch(err) {
-				case GL.INVALID_ENUM: throw "INVALID_ENUM";
-				case GL.INVALID_VALUE: throw "INVALID_VALUE";
-				case GL.INVALID_OPERATION: throw "INVALID_OPERATION";
-				case 1286: throw "INVALID_FRAMEBUFFER_OPERATION";
-				default: throw "Error: " + err;
-			}
-		}
-	}
-
 	#end
 
 	static var TFILTERS = [