From 6c00b5cfc40bc798ea519be30442aa5d0c64ddfb Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 14 Oct 2021 18:51:39 +0100 Subject: [PATCH] Added onPreCopy --- .../webgl/pipelines/SpriteFXPipeline.js | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/renderer/webgl/pipelines/SpriteFXPipeline.js b/src/renderer/webgl/pipelines/SpriteFXPipeline.js index 6f9a3b279..80950024f 100644 --- a/src/renderer/webgl/pipelines/SpriteFXPipeline.js +++ b/src/renderer/webgl/pipelines/SpriteFXPipeline.js @@ -439,12 +439,15 @@ var SpriteFXPipeline = new Class({ return true; }, + // eslint-disable-next-line no-unused-vars + onPreDrawSprite: function (target) + { + }, + drawSprite: function (target, clear) { if (clear === undefined) { clear = false; } - // window.spector.setMarker('drawSprite'); - var gl = this.gl; var data = this.spriteData; @@ -452,6 +455,8 @@ var SpriteFXPipeline = new Class({ this.set1i('uMainSampler', 0); + this.onPreDrawSprite(target); + this.renderer.setTextureZero(data.texture); gl.viewport(0, 0, this.renderer.width, this.renderer.height); @@ -478,8 +483,6 @@ var SpriteFXPipeline = new Class({ gl.bindFramebuffer(gl.FRAMEBUFFER, null); this.renderer.clearTextureZero(); - - // window.spector.clearMarker(); }, getFrameFromSize: function (size) @@ -523,6 +526,11 @@ var SpriteFXPipeline = new Class({ this.drawToGame(target); }, + // eslint-disable-next-line no-unused-vars + onPreCopy: function (source, target) + { + }, + // Draws source to target using the copyShader (which you override in your pipeline) copyFrame: function (source, target, clear, clearAlpha, eraseMode) { @@ -530,8 +538,6 @@ var SpriteFXPipeline = new Class({ if (clearAlpha === undefined) { clearAlpha = true; } if (eraseMode === undefined) { eraseMode = false; } - // window.spector.setMarker('CF' + this.copies); - var gl = this.gl; this.currentShader = this.copyShader; @@ -540,14 +546,9 @@ var SpriteFXPipeline = new Class({ this.copyShader.bind(wasBound, false); - // Need to invoke a callback that sets uniforms? - - this.onPreRender(); - this.set1i('uMainSampler', 0); - // this.set1f('uStrength', 1); - // this.set3fv('uColor', [ 1, 1, 1 ]); + this.onPreCopy(source, target); gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, source.texture); @@ -599,8 +600,6 @@ var SpriteFXPipeline = new Class({ gl.bindFramebuffer(gl.FRAMEBUFFER, null); gl.bindTexture(gl.TEXTURE_2D, null); - - // window.spector.clearMarker(); }, /** @@ -626,8 +625,6 @@ var SpriteFXPipeline = new Class({ var gl = this.gl; var renderer = this.renderer; - // window.spector.setMarker('ToGame'); - this.currentShader = null; if (useCopyShader) @@ -680,8 +677,6 @@ var SpriteFXPipeline = new Class({ gl.bindFramebuffer(gl.FRAMEBUFFER, null); gl.bindTexture(gl.TEXTURE_2D, null); - - // window.spector.clearMarker(); } });