diff --git a/src/repa-shader.js b/src/repa-shader.js index f90c90f..33db705 100644 --- a/src/repa-shader.js +++ b/src/repa-shader.js @@ -326,6 +326,7 @@ class RepaShader extends HTMLElement { this._textures.forEach((t) => { this._uniLocation[t.texElement.name] = this._gl.getUniformLocation(this.program, t.texElement.name); // texture this._uniLocation[t.texElement.name+'_d'] = this._gl.getUniformLocation(this.program, t.texElement.name+'_d'); // dimensions + t.texElement.forceUpdate(); }); this._attLocation = this._gl.getAttribLocation(this.program, 'position'); @@ -377,7 +378,7 @@ class RepaShader extends HTMLElement { } this._gl.uniform1i(this._uniLocation[t.texElement.name], i + this.mrt); - // TODO dimension + this._gl.uniform2fv(this._uniLocation[t.texElement.name+'_d'], [t.texElement.width || 1, t.texElement.height || 1]); }); this._gl.drawArrays(this._gl.TRIANGLE_STRIP, 0, 4); @@ -535,6 +536,7 @@ void main() { return this._textures.map(t => { return ` uniform sampler2D ${t.texElement.name}; + uniform vec2 ${t.texElement.name}_d; `; }).join(''); } diff --git a/src/repa-texture.js b/src/repa-texture.js index cbc2d13..f930d6b 100644 --- a/src/repa-texture.js +++ b/src/repa-texture.js @@ -242,6 +242,10 @@ class RepaTexture extends HTMLElement { return this.content; } + forceUpdate() { + this._forceUpdate = true; + } + get shouldUpdate() { return this.ready && (this._forceUpdate || (this.ref && this.ref instanceof HTMLVideoElement && this.ref.readyState === this.ref.HAVE_ENOUGH_DATA)); }