Skip to content

Commit

Permalink
update global webgl context before calling texture methods, fixes eva…
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 10, 2013
1 parent a8a03b4 commit eddd11e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/core/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ function clamp(lo, value, hi) {
function wrapTexture(texture) {
return {
_: texture,
loadContentsOf: function(element) { this._.loadContentsOf(element); },
destroy: function() { this._.destroy(); }
loadContentsOf: function(element) {
// Make sure that we're using the correct global WebGL context
gl = this._.gl;
this._.loadContentsOf(element);
},
destroy: function() {
// Make sure that we're using the correct global WebGL context
gl = this._.gl;
this._.destroy();
}
};
}

Expand Down
1 change: 1 addition & 0 deletions src/core/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var Texture = (function() {
};

function Texture(width, height, format, type) {
this.gl = gl;
this.id = gl.createTexture();
this.width = width;
this.height = height;
Expand Down
9 changes: 5 additions & 4 deletions tests/texture.loadContentsOf.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<script>

window.onload = function() {
var canvas = fx.canvas();
document.body.appendChild(canvas);
var texture = canvas.texture(document.getElementById('imageA'));
var canvasA = fx.canvas();
document.body.appendChild(canvasA);
var texture = canvasA.texture(document.getElementById('imageA'));
var canvasB = fx.canvas();
texture.loadContentsOf(document.getElementById('imageB'));
canvas.draw(texture).update();
canvasA.draw(texture).update();
};

</script>
Expand Down

0 comments on commit eddd11e

Please sign in to comment.