diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 4d4653b..a41e1e5 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -136,8 +136,6 @@ this.renderingToScreen = true; - this._nextTextureLocation = 0; - this._initContext(); } @@ -242,7 +240,6 @@ { return; } - this._nextTextureLocation = 0; if (!renderTexture) { diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 4d4653b..a41e1e5 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -136,8 +136,6 @@ this.renderingToScreen = true; - this._nextTextureLocation = 0; - this._initContext(); } @@ -242,7 +240,6 @@ { return; } - this._nextTextureLocation = 0; if (!renderTexture) { diff --git a/src/core/renderers/webgl/systems/ProjectionSystem.js b/src/core/renderers/webgl/systems/ProjectionSystem.js index 33fe65e..d8cb662 100644 --- a/src/core/renderers/webgl/systems/ProjectionSystem.js +++ b/src/core/renderers/webgl/systems/ProjectionSystem.js @@ -19,44 +19,15 @@ this.projectionMatrix = new Matrix(); } - update(destinationFrame, sourceFrame, root) + update(destinationFrame, sourceFrame, resolution, root) { this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame; this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame; - this.calculateProjection(this.destinationFrame, this.sourceFrame, root); + this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root); this.renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix; this.renderer.globalUniforms.update(); - - const gl = this.renderer.gl; - - // TODO this is bot needed here? - const resolution = 1; - - // TODO add a check as them may be the same! - if (this.destinationFrame !== this.sourceFrame) - { -// gl.enable(gl.SCISSOR_TEST); - gl.scissor( - this.destinationFrame.x | 0, - this.destinationFrame.y | 0, - (this.destinationFrame.width * resolution) | 0, - (this.destinationFrame.height * resolution) | 0 - ); - } - else - { - // gl.disable(gl.SCISSOR_TEST); - } - - // TODO - does not need to be updated all the time?? - gl.viewport( - this.destinationFrame.x | 0, - this.destinationFrame.y | 0, - (this.destinationFrame.width * resolution) | 0, - (this.destinationFrame.height * resolution) | 0 - ); } /** @@ -65,7 +36,7 @@ * @param {Rectangle} destinationFrame - The destination frame. * @param {Rectangle} sourceFrame - The source frame. */ - calculateProjection(destinationFrame, sourceFrame, root) + calculateProjection(destinationFrame, sourceFrame, resolution, root) { const pm = this.projectionMatrix; @@ -79,6 +50,7 @@ pm.tx = -1 - (sourceFrame.x * pm.a); pm.ty = -1 - (sourceFrame.y * pm.d); + } else { @@ -88,6 +60,11 @@ pm.tx = -1 - (sourceFrame.x * pm.a); pm.ty = 1 - (sourceFrame.y * pm.d); } + + // apply the resolution.. + // TODO - prob should apply this to x and y too! + pm.a *= resolution; + pm.d *= resolution; } diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 4d4653b..a41e1e5 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -136,8 +136,6 @@ this.renderingToScreen = true; - this._nextTextureLocation = 0; - this._initContext(); } @@ -242,7 +240,6 @@ { return; } - this._nextTextureLocation = 0; if (!renderTexture) { diff --git a/src/core/renderers/webgl/systems/ProjectionSystem.js b/src/core/renderers/webgl/systems/ProjectionSystem.js index 33fe65e..d8cb662 100644 --- a/src/core/renderers/webgl/systems/ProjectionSystem.js +++ b/src/core/renderers/webgl/systems/ProjectionSystem.js @@ -19,44 +19,15 @@ this.projectionMatrix = new Matrix(); } - update(destinationFrame, sourceFrame, root) + update(destinationFrame, sourceFrame, resolution, root) { this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame; this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame; - this.calculateProjection(this.destinationFrame, this.sourceFrame, root); + this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root); this.renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix; this.renderer.globalUniforms.update(); - - const gl = this.renderer.gl; - - // TODO this is bot needed here? - const resolution = 1; - - // TODO add a check as them may be the same! - if (this.destinationFrame !== this.sourceFrame) - { -// gl.enable(gl.SCISSOR_TEST); - gl.scissor( - this.destinationFrame.x | 0, - this.destinationFrame.y | 0, - (this.destinationFrame.width * resolution) | 0, - (this.destinationFrame.height * resolution) | 0 - ); - } - else - { - // gl.disable(gl.SCISSOR_TEST); - } - - // TODO - does not need to be updated all the time?? - gl.viewport( - this.destinationFrame.x | 0, - this.destinationFrame.y | 0, - (this.destinationFrame.width * resolution) | 0, - (this.destinationFrame.height * resolution) | 0 - ); } /** @@ -65,7 +36,7 @@ * @param {Rectangle} destinationFrame - The destination frame. * @param {Rectangle} sourceFrame - The source frame. */ - calculateProjection(destinationFrame, sourceFrame, root) + calculateProjection(destinationFrame, sourceFrame, resolution, root) { const pm = this.projectionMatrix; @@ -79,6 +50,7 @@ pm.tx = -1 - (sourceFrame.x * pm.a); pm.ty = -1 - (sourceFrame.y * pm.d); + } else { @@ -88,6 +60,11 @@ pm.tx = -1 - (sourceFrame.x * pm.a); pm.ty = 1 - (sourceFrame.y * pm.d); } + + // apply the resolution.. + // TODO - prob should apply this to x and y too! + pm.a *= resolution; + pm.d *= resolution; } diff --git a/src/core/renderers/webgl/systems/RenderTextureSystem.js b/src/core/renderers/webgl/systems/RenderTextureSystem.js index 7376934..e37d086 100644 --- a/src/core/renderers/webgl/systems/RenderTextureSystem.js +++ b/src/core/renderers/webgl/systems/RenderTextureSystem.js @@ -34,9 +34,11 @@ if(renderTexture) { - this.renderer.framebuffer.bind(renderTexture.baseTexture.frameBuffer); - this.renderer.projection.update(renderTexture.frame, renderTexture.frame, false); - this.renderer.stencil.setMaskStack(renderTexture.baseTexture.stencilMaskStack); + const baseTexture = renderTexture.baseTexture; + + this.renderer.framebuffer.bind(baseRenderTexture.frameBuffer); + this.renderer.projection.update(renderTexture.frame, renderTexture.frame, baseRenderTexture.resolution, false); + this.renderer.stencil.setMaskStack(baseTexture.stencilMaskStack); } else @@ -46,7 +48,7 @@ tempRect.width = renderer.width; tempRect.height = renderer.height; // TODO store this.. - this.renderer.projection.update(tempRect, tempRect, true); + this.renderer.projection.update(tempRect, tempRect, this.renderer.resolution, true); this.renderer.stencil.setMaskStack(this.defaultMaskStack); }