Skip to content

Commit

Permalink
update shape on each draw call
Browse files Browse the repository at this point in the history
  • Loading branch information
thejohnhoffer committed May 16, 2018
1 parent 289685a commit 75bec9b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tools/viaWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,24 @@ ViaWebGL.prototype = {
this.width = source.width;
}
this.source = source;
this.gl.canvas.width = this.width;
this.gl.canvas.height = this.height;
this.gl.viewport(0, 0, this.width, this.height);
this.updateShape(this.height, this.width);

// Load the shaders when ready and return the promise
var step = [[this.vShader, this.fShader].map(this.getter)];
step.push(this.toProgram.bind(this), this.toBuffers.bind(this));
return Promise.all(step[0]).then(step[1]).then(step[2]).then(this.ready);

},

updateShape: function(width, height) {

this.width = width;
this.height = height;
this.gl.canvas.width = width;
this.gl.canvas.height = height;
this.gl.viewport(0, 0, this.width, this.height);
},

// Make a canvas
maker: function(options){
return this.context(document.createElement('canvas'));
Expand Down Expand Up @@ -164,6 +173,8 @@ ViaWebGL.prototype = {
}
return tile;
}
// Update shape for image or canvas
this.updateShape(tile.width, tile.height);

// Allow for custom drawing in webGL
this['gl-drawing'].call(this,tile);
Expand Down

0 comments on commit 75bec9b

Please sign in to comment.