mirror of
https://github.com/photonstorm/phaser
synced 2024-11-17 10:18:42 +00:00
Store and restore previous framebuffer
This commit is contained in:
parent
e07248a403
commit
93dabaa34e
1 changed files with 56 additions and 2 deletions
|
@ -115,6 +115,15 @@ var BitmapMask = new Class({
|
|||
*/
|
||||
this.maskFramebuffer = null;
|
||||
|
||||
/**
|
||||
* The previous framebuffer set in the renderer before this one was enabled.
|
||||
*
|
||||
* @name Phaser.Display.Masks.BitmapMask#prevFramebuffer
|
||||
* @type {WebGLFramebuffer}
|
||||
* @since 3.17.0
|
||||
*/
|
||||
this.prevFramebuffer = null;
|
||||
|
||||
/**
|
||||
* Whether to invert the mask's alpha.
|
||||
*
|
||||
|
@ -126,6 +135,8 @@ var BitmapMask = new Class({
|
|||
*/
|
||||
this.invertAlpha = false;
|
||||
|
||||
this.isStencil = false;
|
||||
|
||||
if (renderer && renderer.gl)
|
||||
{
|
||||
var width = renderer.width;
|
||||
|
@ -185,7 +196,21 @@ var BitmapMask = new Class({
|
|||
*/
|
||||
preRenderWebGL: function (renderer, maskedObject, camera)
|
||||
{
|
||||
// if (renderer.maskStack.length === 0)
|
||||
// {
|
||||
// renderer.maskCount = 0;
|
||||
// }
|
||||
|
||||
// if (renderer.currentCameraMask !== this)
|
||||
// {
|
||||
// renderer.currentMask = this;
|
||||
// }
|
||||
|
||||
// renderer.maskStack.push({ mask: this, camera: camera });
|
||||
|
||||
renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera);
|
||||
|
||||
// renderer.maskCount++;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -198,9 +223,37 @@ var BitmapMask = new Class({
|
|||
*
|
||||
* @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The WebGL Renderer to clean up.
|
||||
*/
|
||||
postRenderWebGL: function (renderer)
|
||||
postRenderWebGL: function (renderer, camera)
|
||||
{
|
||||
renderer.pipelines.BitmapMaskPipeline.endMask(this);
|
||||
renderer.pipelines.BitmapMaskPipeline.endMask(this, camera);
|
||||
|
||||
/*
|
||||
renderer.maskStack.pop();
|
||||
|
||||
renderer.maskCount--;
|
||||
|
||||
if (renderer.maskStack.length === 0)
|
||||
{
|
||||
renderer.pipelines.BitmapMaskPipeline.endMask(this);
|
||||
|
||||
renderer.currentMask = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the mask previous to this one
|
||||
var prev = renderer.maskStack[renderer.maskStack.length - 1];
|
||||
var bitmapMask = prev.mask;
|
||||
|
||||
// var camera = prev.camera;
|
||||
|
||||
if (renderer.currentCameraMask !== bitmapMask)
|
||||
{
|
||||
renderer.currentMask = bitmapMask;
|
||||
}
|
||||
|
||||
renderer.setFramebuffer(bitmapMask.mainFramebuffer);
|
||||
}
|
||||
*/
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -258,6 +311,7 @@ var BitmapMask = new Class({
|
|||
this.maskTexture = null;
|
||||
this.mainFramebuffer = null;
|
||||
this.maskFramebuffer = null;
|
||||
this.prevFramebuffer = null;
|
||||
this.renderer = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue