Commits

Philipp Tiefenbacher  committed 92ab75b Draft

working readpixels proof of concept

  • Participants
  • Parent commits 4ab4a82

Comments (0)

Files changed (2)

File src/game/CellSpace.js

 require(["jquery", "Utils", "CellSpaceResources", "EvoCell"], function($, utils, resources, EC) {
 	var keyboard = utils.keyboard;
 	var gameW = 256, gameH = 256;
-	var zoom = 2;
+	gameW = 512, gameH = 512;
+	var zoom = 1;
 	
 	var fpsMonotor = new utils.FPSMonitor("fpsMonitor");
 
 					texSource: enemy2Dish, sourcePos: [5, 10], sourceRes: [gameW, gameH], 	
 					}); 
 
+				var pixelValues = new Uint8Array(10*10*4);
+				var gl = reactor.gl;
+
+				gl.bindFramebuffer(gl.FRAMEBUFFER, bufferDish.getCurrentFramebuffer());
+				gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, bufferDish.getCurrentTexture(), 0);
+				var xyz = gl.readPixels(0, 0, 10, 10, gl.RGBA, gl.UNSIGNED_BYTE, pixelValues);
+
 				//var pattern = bufferDish.saveAsECFile();
 				var ruleAsBlob = data.enemyRule.saveToBlob();
-				utils.saveAs(ruleAsBlob, "ecPattern");
+				//utils.saveAs(ruleAsBlob, "ecPattern");
 
 				reactor.mixDish(copyShader, copyDish, {
 					destinationPos: [120, 100], destinationSize: [bufferDish.width, bufferDish.height],

File src/game/gl/Dish.js

 		return (this.frameFlip > 0) ? this.texture1 : this.texture2;
 	}
 
+	Dish.prototype.getCurrentFramebuffer = function()
+	{
+		return (this.frameFlip > 0) ? this.fb1 : this.fb2;
+	}
+
 	Dish.prototype.getNextFramebuffer = function() 
 	{
 		return (this.frameFlip > 0) ? this.fb2 : this.fb1;