ソースを参照

Adding a ReadPixels method, to wrap WebGL call.

Nicolas Obré 11 年 前
コミット
359241f490
2 ファイル変更11 行追加0 行削除
  1. 6 0
      Babylon/babylon.engine.js
  2. 5 0
      Babylon/babylon.engine.ts

+ 6 - 0
Babylon/babylon.engine.js

@@ -1121,6 +1121,12 @@
             }
         };
 
+        Engine.prototype.ReadPixels = function (x, y, width, height) {
+            var data = new Uint8Array(height * width * 4);
+            this._gl.readPixels(0, 0, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
+            return data;
+        };
+
         // Dispose
         Engine.prototype.dispose = function () {
             while (this.scenes.length) {

+ 5 - 0
Babylon/babylon.engine.ts

@@ -1176,6 +1176,11 @@
             }
         }
 
+        public ReadPixels(x: number, y: number, width: number, height: number) : Uint8Array {
+            var data = new Uint8Array(height * width * 4);
+            this._gl.readPixels(0, 0, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
+            return data;
+        }
         // Dispose
         public dispose(): void {
             // Release scenes