diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/renderers/webgl/RenderTextureManager.js b/src/core/renderers/webgl/RenderTextureManager.js index a5b639b..cbbbd4c 100644 --- a/src/core/renderers/webgl/RenderTextureManager.js +++ b/src/core/renderers/webgl/RenderTextureManager.js @@ -58,7 +58,7 @@ RenderTextureManager.prototype.destroyTexture = function(texture, _skipRemove) { texture = texture.baseTexture || texture; - + var gl = this.gl; if (texture._glRenderTargets[gl.id]) { diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/renderers/webgl/RenderTextureManager.js b/src/core/renderers/webgl/RenderTextureManager.js index a5b639b..cbbbd4c 100644 --- a/src/core/renderers/webgl/RenderTextureManager.js +++ b/src/core/renderers/webgl/RenderTextureManager.js @@ -58,7 +58,7 @@ RenderTextureManager.prototype.destroyTexture = function(texture, _skipRemove) { texture = texture.baseTexture || texture; - + var gl = this.gl; if (texture._glRenderTargets[gl.id]) { diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 323daa5..6a0efa7 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -172,7 +172,7 @@ * * @param object {PIXI.DisplayObject} the object to be rendered */ -WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, skipUpdateTransform) +WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { this.emit('prerender'); @@ -193,7 +193,7 @@ displayObject.parent = cacheParent; } - this.bindRenderTexture(renderTexture); + this.bindRenderTexture(renderTexture, transform); if( clear || this.clearBeforeRender) { @@ -202,6 +202,8 @@ displayObject.renderWebGL(this); + // apply transform.. + this.currentRenderer.flush(); this.emit('postrender'); @@ -257,8 +259,13 @@ this._activeRenderTarget.clear(clearColor); } +WebGLRenderer.prototype.setTransform = function (matrix) +{ + this._activeRenderTarget.transform = matrix; +} + //TOOD - required? -WebGLRenderer.prototype.bindRenderTexture = function (renderTexture) +WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { if(renderTexture) { @@ -278,6 +285,7 @@ renderTarget = this.rootRenderTarget; } + renderTarget.transform = transform; this.bindRenderTarget(renderTarget); return this; diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/renderers/webgl/RenderTextureManager.js b/src/core/renderers/webgl/RenderTextureManager.js index a5b639b..cbbbd4c 100644 --- a/src/core/renderers/webgl/RenderTextureManager.js +++ b/src/core/renderers/webgl/RenderTextureManager.js @@ -58,7 +58,7 @@ RenderTextureManager.prototype.destroyTexture = function(texture, _skipRemove) { texture = texture.baseTexture || texture; - + var gl = this.gl; if (texture._glRenderTargets[gl.id]) { diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 323daa5..6a0efa7 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -172,7 +172,7 @@ * * @param object {PIXI.DisplayObject} the object to be rendered */ -WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, skipUpdateTransform) +WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { this.emit('prerender'); @@ -193,7 +193,7 @@ displayObject.parent = cacheParent; } - this.bindRenderTexture(renderTexture); + this.bindRenderTexture(renderTexture, transform); if( clear || this.clearBeforeRender) { @@ -202,6 +202,8 @@ displayObject.renderWebGL(this); + // apply transform.. + this.currentRenderer.flush(); this.emit('postrender'); @@ -257,8 +259,13 @@ this._activeRenderTarget.clear(clearColor); } +WebGLRenderer.prototype.setTransform = function (matrix) +{ + this._activeRenderTarget.transform = matrix; +} + //TOOD - required? -WebGLRenderer.prototype.bindRenderTexture = function (renderTexture) +WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { if(renderTexture) { @@ -278,6 +285,7 @@ renderTarget = this.rootRenderTarget; } + renderTarget.transform = transform; this.bindRenderTarget(renderTarget); return this; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index ea43d6a..ced94f6 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -131,24 +131,25 @@ */ this.root = root; - this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); - + if (!this.root) { + this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); + /* A frame buffer needs a target to render to.. create a texture and bind it attach it to the framebuffer.. */ - - // TODO change! // this is used by the base texture this.texture = this.frameBuffer.texture; } else { // make it a null framebuffer.. + this.frameBuffer = new GLFramebuffer(gl, 100, 100); this.frameBuffer.framebuffer = null; + } this.setFrame(); @@ -203,8 +204,6 @@ var gl = this.gl; // make surethe texture is unbound! - this.frameBuffer.texture.unbind(); - this.frameBuffer.bind(); this.calculateProjection( this.destinationFrame, this.sourceFrame ); diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/renderers/webgl/RenderTextureManager.js b/src/core/renderers/webgl/RenderTextureManager.js index a5b639b..cbbbd4c 100644 --- a/src/core/renderers/webgl/RenderTextureManager.js +++ b/src/core/renderers/webgl/RenderTextureManager.js @@ -58,7 +58,7 @@ RenderTextureManager.prototype.destroyTexture = function(texture, _skipRemove) { texture = texture.baseTexture || texture; - + var gl = this.gl; if (texture._glRenderTargets[gl.id]) { diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 323daa5..6a0efa7 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -172,7 +172,7 @@ * * @param object {PIXI.DisplayObject} the object to be rendered */ -WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, skipUpdateTransform) +WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { this.emit('prerender'); @@ -193,7 +193,7 @@ displayObject.parent = cacheParent; } - this.bindRenderTexture(renderTexture); + this.bindRenderTexture(renderTexture, transform); if( clear || this.clearBeforeRender) { @@ -202,6 +202,8 @@ displayObject.renderWebGL(this); + // apply transform.. + this.currentRenderer.flush(); this.emit('postrender'); @@ -257,8 +259,13 @@ this._activeRenderTarget.clear(clearColor); } +WebGLRenderer.prototype.setTransform = function (matrix) +{ + this._activeRenderTarget.transform = matrix; +} + //TOOD - required? -WebGLRenderer.prototype.bindRenderTexture = function (renderTexture) +WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { if(renderTexture) { @@ -278,6 +285,7 @@ renderTarget = this.rootRenderTarget; } + renderTarget.transform = transform; this.bindRenderTarget(renderTarget); return this; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index ea43d6a..ced94f6 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -131,24 +131,25 @@ */ this.root = root; - this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); - + if (!this.root) { + this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); + /* A frame buffer needs a target to render to.. create a texture and bind it attach it to the framebuffer.. */ - - // TODO change! // this is used by the base texture this.texture = this.frameBuffer.texture; } else { // make it a null framebuffer.. + this.frameBuffer = new GLFramebuffer(gl, 100, 100); this.frameBuffer.framebuffer = null; + } this.setFrame(); @@ -203,8 +204,6 @@ var gl = this.gl; // make surethe texture is unbound! - this.frameBuffer.texture.unbind(); - this.frameBuffer.bind(); this.calculateProjection( this.destinationFrame, this.sourceFrame ); diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 0174888..ed664d3 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -121,35 +121,13 @@ }; /** - * Clears the BaseRenderTexture. - * - */ -BaseRenderTexture.prototype.clear = function (destinationFrame) -{ - if (!this.valid) - { - return; - } - - if (this.renderer.type === CONST.RENDERER_TYPE.WEBGL) - { - this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer); - } - - this.textureBuffer.clear(false, destinationFrame); -}; - - -/** * Destroys this texture * * @param destroyBase {boolean} Whether to destroy the base texture as well */ BaseRenderTexture.prototype.destroy = function () { - Texture.prototype.destroy.call(this, true); - - this.textureBuffer.destroy(); + BaseTexture.prototype.destroy.call(this, true); // destroy the filtermanager.. if(this.filterManager) diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/renderers/webgl/RenderTextureManager.js b/src/core/renderers/webgl/RenderTextureManager.js index a5b639b..cbbbd4c 100644 --- a/src/core/renderers/webgl/RenderTextureManager.js +++ b/src/core/renderers/webgl/RenderTextureManager.js @@ -58,7 +58,7 @@ RenderTextureManager.prototype.destroyTexture = function(texture, _skipRemove) { texture = texture.baseTexture || texture; - + var gl = this.gl; if (texture._glRenderTargets[gl.id]) { diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 323daa5..6a0efa7 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -172,7 +172,7 @@ * * @param object {PIXI.DisplayObject} the object to be rendered */ -WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, skipUpdateTransform) +WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { this.emit('prerender'); @@ -193,7 +193,7 @@ displayObject.parent = cacheParent; } - this.bindRenderTexture(renderTexture); + this.bindRenderTexture(renderTexture, transform); if( clear || this.clearBeforeRender) { @@ -202,6 +202,8 @@ displayObject.renderWebGL(this); + // apply transform.. + this.currentRenderer.flush(); this.emit('postrender'); @@ -257,8 +259,13 @@ this._activeRenderTarget.clear(clearColor); } +WebGLRenderer.prototype.setTransform = function (matrix) +{ + this._activeRenderTarget.transform = matrix; +} + //TOOD - required? -WebGLRenderer.prototype.bindRenderTexture = function (renderTexture) +WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { if(renderTexture) { @@ -278,6 +285,7 @@ renderTarget = this.rootRenderTarget; } + renderTarget.transform = transform; this.bindRenderTarget(renderTarget); return this; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index ea43d6a..ced94f6 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -131,24 +131,25 @@ */ this.root = root; - this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); - + if (!this.root) { + this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); + /* A frame buffer needs a target to render to.. create a texture and bind it attach it to the framebuffer.. */ - - // TODO change! // this is used by the base texture this.texture = this.frameBuffer.texture; } else { // make it a null framebuffer.. + this.frameBuffer = new GLFramebuffer(gl, 100, 100); this.frameBuffer.framebuffer = null; + } this.setFrame(); @@ -203,8 +204,6 @@ var gl = this.gl; // make surethe texture is unbound! - this.frameBuffer.texture.unbind(); - this.frameBuffer.bind(); this.calculateProjection( this.destinationFrame, this.sourceFrame ); diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 0174888..ed664d3 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -121,35 +121,13 @@ }; /** - * Clears the BaseRenderTexture. - * - */ -BaseRenderTexture.prototype.clear = function (destinationFrame) -{ - if (!this.valid) - { - return; - } - - if (this.renderer.type === CONST.RENDERER_TYPE.WEBGL) - { - this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer); - } - - this.textureBuffer.clear(false, destinationFrame); -}; - - -/** * Destroys this texture * * @param destroyBase {boolean} Whether to destroy the base texture as well */ BaseRenderTexture.prototype.destroy = function () { - Texture.prototype.destroy.call(this, true); - - this.textureBuffer.destroy(); + BaseTexture.prototype.destroy.call(this, true); // destroy the filtermanager.. if(this.filterManager) diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index e8ef618..67b03d7 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -99,72 +99,6 @@ this._updateUvs(); }; -/** - * Clears the RenderTexture. - * - */ -RenderTexture.prototype.clear = function () -{ - if (!this.valid) - { - return; - } - - this.baseTexture.clear(this.frame) - -}; - -/** - * Will return a HTML Image of the texture - * - * @return {Image} - */ -RenderTexture.prototype.getImage = function () -{ - return this.baseTexture.getImage(this.frame); -}; - -/** - * Will return a a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that. - * - * @return {string} A base64 encoded string of the texture. - */ -RenderTexture.prototype.getBase64 = function () -{ - return this.getBase64.getImage(this.frame); -}; - -/** - * Creates a Canvas element, renders this RenderTexture to it and then returns it. - * - * @return {HTMLCanvasElement} A Canvas element with the texture rendered on. - */ -RenderTexture.prototype.getCanvas = function () -{ - return this.baseTexture.getCanvas(this.frame); -}; - -/** - * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA order, with integer values between 0 and 255 (included). - * - * @return {Uint8ClampedArray} - */ -RenderTexture.prototype.getPixels = function () -{ - return this.baseTexture.getPixels(this.frame); -}; - -/** - * Will return a one-dimensional array containing the pixel data of a pixel within the texture in RGBA order, with integer values between 0 and 255 (included). - * - * @param x {number} The x coordinate of the pixel to retrieve. - * @param y {number} The y coordinate of the pixel to retrieve. - * @return {Uint8ClampedArray} - */ -RenderTexture.prototype.getPixel = function (x, y) -{ - return this.baseTexture.getPixel(this.frame, x, y); -}; RenderTexture.create = function(width, height, scaleMode, resolution) { diff --git a/src/core/display/Container.js b/src/core/display/Container.js index fef5ef9..6e91a27 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -485,16 +485,16 @@ */ Container.prototype.getLocalBounds = function () { - var matrixCache = this.worldTransform; + var matrixCache = this.transform.worldTransform; - this.worldTransform = math.Matrix.IDENTITY; + this.transform.worldTransform = math.Matrix.IDENTITY; for (var i = 0, j = this.children.length; i < j; ++i) { this.children[i].updateTransform(); } - this.worldTransform = matrixCache; + this.transform.worldTransform = matrixCache; this._currentBounds = null; diff --git a/src/core/renderers/webgl/RenderTextureManager.js b/src/core/renderers/webgl/RenderTextureManager.js index a5b639b..cbbbd4c 100644 --- a/src/core/renderers/webgl/RenderTextureManager.js +++ b/src/core/renderers/webgl/RenderTextureManager.js @@ -58,7 +58,7 @@ RenderTextureManager.prototype.destroyTexture = function(texture, _skipRemove) { texture = texture.baseTexture || texture; - + var gl = this.gl; if (texture._glRenderTargets[gl.id]) { diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 323daa5..6a0efa7 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -172,7 +172,7 @@ * * @param object {PIXI.DisplayObject} the object to be rendered */ -WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, skipUpdateTransform) +WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { this.emit('prerender'); @@ -193,7 +193,7 @@ displayObject.parent = cacheParent; } - this.bindRenderTexture(renderTexture); + this.bindRenderTexture(renderTexture, transform); if( clear || this.clearBeforeRender) { @@ -202,6 +202,8 @@ displayObject.renderWebGL(this); + // apply transform.. + this.currentRenderer.flush(); this.emit('postrender'); @@ -257,8 +259,13 @@ this._activeRenderTarget.clear(clearColor); } +WebGLRenderer.prototype.setTransform = function (matrix) +{ + this._activeRenderTarget.transform = matrix; +} + //TOOD - required? -WebGLRenderer.prototype.bindRenderTexture = function (renderTexture) +WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { if(renderTexture) { @@ -278,6 +285,7 @@ renderTarget = this.rootRenderTarget; } + renderTarget.transform = transform; this.bindRenderTarget(renderTarget); return this; diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index ea43d6a..ced94f6 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -131,24 +131,25 @@ */ this.root = root; - this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); - + if (!this.root) { + this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); + /* A frame buffer needs a target to render to.. create a texture and bind it attach it to the framebuffer.. */ - - // TODO change! // this is used by the base texture this.texture = this.frameBuffer.texture; } else { // make it a null framebuffer.. + this.frameBuffer = new GLFramebuffer(gl, 100, 100); this.frameBuffer.framebuffer = null; + } this.setFrame(); @@ -203,8 +204,6 @@ var gl = this.gl; // make surethe texture is unbound! - this.frameBuffer.texture.unbind(); - this.frameBuffer.bind(); this.calculateProjection( this.destinationFrame, this.sourceFrame ); diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 0174888..ed664d3 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -121,35 +121,13 @@ }; /** - * Clears the BaseRenderTexture. - * - */ -BaseRenderTexture.prototype.clear = function (destinationFrame) -{ - if (!this.valid) - { - return; - } - - if (this.renderer.type === CONST.RENDERER_TYPE.WEBGL) - { - this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer); - } - - this.textureBuffer.clear(false, destinationFrame); -}; - - -/** * Destroys this texture * * @param destroyBase {boolean} Whether to destroy the base texture as well */ BaseRenderTexture.prototype.destroy = function () { - Texture.prototype.destroy.call(this, true); - - this.textureBuffer.destroy(); + BaseTexture.prototype.destroy.call(this, true); // destroy the filtermanager.. if(this.filterManager) diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index e8ef618..67b03d7 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -99,72 +99,6 @@ this._updateUvs(); }; -/** - * Clears the RenderTexture. - * - */ -RenderTexture.prototype.clear = function () -{ - if (!this.valid) - { - return; - } - - this.baseTexture.clear(this.frame) - -}; - -/** - * Will return a HTML Image of the texture - * - * @return {Image} - */ -RenderTexture.prototype.getImage = function () -{ - return this.baseTexture.getImage(this.frame); -}; - -/** - * Will return a a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that. - * - * @return {string} A base64 encoded string of the texture. - */ -RenderTexture.prototype.getBase64 = function () -{ - return this.getBase64.getImage(this.frame); -}; - -/** - * Creates a Canvas element, renders this RenderTexture to it and then returns it. - * - * @return {HTMLCanvasElement} A Canvas element with the texture rendered on. - */ -RenderTexture.prototype.getCanvas = function () -{ - return this.baseTexture.getCanvas(this.frame); -}; - -/** - * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA order, with integer values between 0 and 255 (included). - * - * @return {Uint8ClampedArray} - */ -RenderTexture.prototype.getPixels = function () -{ - return this.baseTexture.getPixels(this.frame); -}; - -/** - * Will return a one-dimensional array containing the pixel data of a pixel within the texture in RGBA order, with integer values between 0 and 255 (included). - * - * @param x {number} The x coordinate of the pixel to retrieve. - * @param y {number} The y coordinate of the pixel to retrieve. - * @return {Uint8ClampedArray} - */ -RenderTexture.prototype.getPixel = function (x, y) -{ - return this.baseTexture.getPixel(this.frame, x, y); -}; RenderTexture.create = function(width, height, scaleMode, resolution) { diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index a4fd86b..82dc55c 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -87,10 +87,10 @@ this._initCachedDisplayObject( renderer ); + this._cachedSprite.transform.updated = true; this._cachedSprite.worldAlpha = this.worldAlpha; - renderer.setObjectRenderer(renderer.plugins.sprite); - renderer.plugins.sprite.render( this._cachedSprite ); + this._cachedSprite._renderWebGL(renderer); }; /** @@ -127,12 +127,13 @@ // for now we cache the current renderTarget that the webGL renderer is currently using. // this could be more elegent.. - var cachedRenderTarget = renderer.currentRenderTarget; + var cachedRenderTarget = renderer._activeRenderTarget; // We also store the filter stack - I will definitely look to change how this works a little later down the line. var stack = renderer.filterManager.filterStack; // this renderTexture will be used to store the cached DisplayObject - var renderTexture = new core.RenderTexture(renderer, bounds.width | 0, bounds.height | 0); + + var renderTexture = new core.RenderTexture.create(bounds.width | 0, bounds.height | 0); // need to set // var m = _tempMatrix; @@ -140,15 +141,15 @@ m.tx = -bounds.x; m.ty = -bounds.y; - - // set all properties to there original so we can render to a texture this.renderWebGL = this._originalRenderWebGL; - renderTexture.render(this, m, true, true); - +// renderer.clear([0.5, 0.5, 0.5, 0.5]) + renderer.render(this, renderTexture, true, m, true); // now restore the state be setting the new properties - renderer.setRenderTarget(cachedRenderTarget); + + renderer.bindRenderTarget(cachedRenderTarget); + renderer.filterManager.filterStack = stack; this.renderWebGL = this._renderCachedWebGL; @@ -158,7 +159,7 @@ // create our cached sprite this._cachedSprite = new core.Sprite(renderTexture); - this._cachedSprite.worldTransform = this.worldTransform; + this._cachedSprite.transform.worldTransform = this.transform.worldTransform; this._cachedSprite.anchor.x = -( bounds.x / bounds.width ); this._cachedSprite.anchor.y = -( bounds.y / bounds.height ); @@ -231,7 +232,7 @@ // create our cached sprite this._cachedSprite = new core.Sprite(renderTexture); - this._cachedSprite.worldTransform = this.worldTransform; + this._cachedSprite.transform.worldTransform = this.transform.worldTransform; this._cachedSprite.anchor.x = -( bounds.x / bounds.width ); this._cachedSprite.anchor.y = -( bounds.y / bounds.height ); @@ -259,7 +260,7 @@ */ DisplayObject.prototype._destroyCachedDisplayObject = function () { - this._cachedSprite._texture.destroy(); + this._cachedSprite._texture.destroy(true); this._cachedSprite = null; };