Sfoglia il codice sorgente

fixed readPixels for RGBA32F

ncannasse 7 anni fa
parent
commit
50216c51b3
1 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 11 1
      h3d/impl/GlDriver.hx

+ 11 - 1
h3d/impl/GlDriver.hx

@@ -1356,8 +1356,18 @@ class GlDriver extends Driver {
 	override function captureRenderBuffer( pixels : hxd.Pixels ) {
 		if( curTarget == null )
 			throw "Can't capture main render buffer in GL";
+		#if js
+		var buffer : js.html.ArrayBufferView = @:privateAccess pixels.bytes.b;
+		switch( curTarget.format ) {
+		case RGBA32F: buffer = new js.html.Float32Array(buffer.buffer);
+		case RGBA16F: throw "Not supported";
+		default:
+		}
+		#else
+		var buffer = @:privateAccess pixels.bytes.b;
+		#end
 		#if (js || hl)
-		gl.readPixels(0, 0, pixels.width, pixels.height, getChannels(curTarget.t), curTarget.t.pixelFmt, @:privateAccess pixels.bytes.b);
+		gl.readPixels(0, 0, pixels.width, pixels.height, getChannels(curTarget.t), curTarget.t.pixelFmt, buffer);
 		@:privateAccess pixels.innerFormat = curTarget.format;
 		#end
 	}