Commits

Philipp Tiefenbacher committed b396d1e

palette cleanup, testing 2nd glcontext

  • Participants
  • Parent commits 5cd6c06

Comments (0)

Files changed (2)

hackathonAlpha.html

 var ctlXRes, ctlYRes, ctlRandomDensity, ctlNrSims, ctlFramerate;
 var evoCellData;
 
+var caCanvas2;
+
 function setup()
 {
 	ctlXRes = jQuery('#xres')[0];
 
 	//document.getElementById('floatingPalette').addEventListener('click', handleFloatingPaletteClick, false);
 
+	caCanvas = new EvoCell.CACanvas(jQuery("#c")[0]);
+	
 	new Draggable('floatingPalette');
 	
 	jQuery('#evocellFile').change(handleFileSelect);
 	clearInterval(timer);
 
-	caCanvas = new EvoCell.CACanvas(jQuery("#c")[0]);
+	new Draggable('c2');
+	//document.getElementById('c2').addEventListener('contextmenu', handleContextMenu, false);
+	document.getElementById('c2').addEventListener('click', handleCanvasClick, false);
+	caCanvas2 = new EvoCell.CACanvas(jQuery("#c2")[0]);
+	
+	//caCanvas.gl = caCanvas2.gl;
 	
 	width = 1200;
 	height = 800;
 	
 	randomDensity = parseFloat(ctlRandomDensity.value);
 	caCanvas.setSize(width, height);
+
+	caCanvas2.setSize(colWidth, rowHeight);
 	//caSim.setSize(width, height);
 	
 	oldSims = caSims;
 				[(width / nrSimsCols) * (c + 0.5) - colWidth/2, (height / nrSimsRows) * (r + 0.5) - rowHeight/2, colWidth, rowHeight]);
 		}
 	}
+
+	caCanvas2.draw(caSims[0], progShow, null, [0, 0, colWidth, rowHeight]);
+	
 }
 
 function fr(){
 	clickedCA = nrSimsCols * Math.floor(nrSimsRows * (height - coords.y) / height);
 	clickedCA += Math.floor(nrSimsCols * coords.x / width);
 
+	if (evt.target == caCanvas2.canvas)
+	{	
+		alert("sss");	
+		return;
+	}
+	
+
 	if (evt.button == 0) {
 		var mutReg;
 		var mutTarget;
 
 function fillPalette(evoCellData)
 {
-	var leftOffset = 55, topOffset = 75, xOffset = 55;
+	var leftOffset = 60, topOffset = 30, xOffset = 55, yOffset = 25;
 	var s="<div style=\"background-color:#ccf;\">Dont hesitate...MUTATE!</div>";
-	
- 
 	s+="mutations: <input type='number' id='nPattern_mutations' value='1000' style='width:70px;' /> <input type='checkbox' id='nPattern_all' /> All rules ";
-	
+	document.getElementById('floatingPaletteOptions').innerHTML = s;
+	s = "";
+
 	for (var nIndex = 0; nIndex < evoCellData.neighbourhood.length; nIndex++)
 	{
 		var neighbour = evoCellData.neighbourhood[nIndex];
 		var x = neighbour[0];
 		var y = neighbour[1];
 		var posx = leftOffset + x * xOffset;
-		var posy = topOffset + y * 25;
+		var posy = topOffset + y * yOffset;
 
 	 	s+= "<input type=\"text\" id=\"nPattern_" + nIndex + "\" value=\"?\" style=\"position:absolute; width:40px; left:" + posx + "px; top:" + posy + "px;\" />";
 	}
 </head>
 <body onload="setup()">
 
-	<div id="floatingPalette" style="position:fixed; width:240px; height:150px; left:200px; top:200px; background-color:#fdd; cursor:move;">
+	<div id="floatingPalette" style="position:fixed; width:240px; height:150px; background-color:#fdd; cursor:move;">
 	<div id="floatingPaletteHeader"><input type='checkbox' id='paletteStealth' />hide palette</div>
- 	<div id="floatingPaletteNeighbours"></div>
+	<div id="floatingPaletteOptions" style="position:relative;"></div>
+ 	<div id="floatingPaletteNeighbours" style="position:relative;"></div>
 	
 	</div>
 
 	<canvas id="c" width="1000" height="3333"></canvas>
+	<canvas id="c2" width="1000" height="3333"></canvas>
 
 	<form name="controls" action="">
 	<input type="button" id="cmdRunPause" value="run/pause" onclick="pausePlease = !pausePlease; if (!pausePlease) anim();">

src/evocellweb.js

 		
 		this.gl.useProgram(progCA);
 
+		gl.uniform1i(gl.getUniformLocation(progCA, "texRule"), 1);
+		gl.activeTexture(gl.TEXTURE1);    
+		gl.bindTexture(gl.TEXTURE_2D, this.ruleTexture);
+
 		if (this.frameFlip > 0)
 		{
 			gl.uniform1i(gl.getUniformLocation(progCA, "texFrame"), 0);
 			gl.activeTexture(gl.TEXTURE0);    
 			gl.bindTexture(gl.TEXTURE_2D, this.texture1);
 			
-			gl.uniform1i(gl.getUniformLocation(progCA, "texRule"), 1);
-			gl.activeTexture(gl.TEXTURE1);    
-			gl.bindTexture(gl.TEXTURE_2D, this.ruleTexture);
-
 			gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb2);
 		}
 		else
 			gl.uniform1i(gl.getUniformLocation(progCA, "texFrame"), 0);
 			gl.activeTexture(gl.TEXTURE0);    
 			gl.bindTexture(gl.TEXTURE_2D, this.texture2);
-			
-			// TODO: diese 3 zeilen rausziehen
-			gl.uniform1i(gl.getUniformLocation(progCA, "texRule"), 1);
-			gl.activeTexture(gl.TEXTURE1);    
-			gl.bindTexture(gl.TEXTURE_2D, this.ruleTexture);
 		
 			gl.bindFramebuffer(gl.FRAMEBUFFER, this.fb1);
 		}