Fixed scissors when using a small cam with render texture

This commit is contained in:
Richard Davey 2018-08-31 16:25:04 +01:00
parent 79b4f07530
commit 0b95ed0478
3 changed files with 13 additions and 15 deletions

View file

@ -261,6 +261,8 @@ var Camera = new Class({
/**
* Sets the Camera to render to a texture instead of to the main display.
*
* Make sure that you resize the camera first if you're going to use this feature.
*
* This is an experimental feature and should be expected to change in the future.
*
* @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture

View file

@ -1530,14 +1530,14 @@ var WebGLRenderer = new Class({
var cw = camera._cw;
var ch = camera._ch;
this.pushScissor(cx, cy, cw, ch);
var TextureTintPipeline = this.pipelines.TextureTintPipeline;
var color = camera.backgroundColor;
if (camera.renderToTexture)
{
this.pushScissor(cx, cy, cw, -ch);
this.setFramebuffer(camera.framebuffer);
var gl = this.gl;
@ -1546,12 +1546,12 @@ var WebGLRenderer = new Class({
gl.clear(gl.COLOR_BUFFER_BIT);
TextureTintPipeline.projOrtho(0, camera.width, 0, camera.height, -1000, 1000);
TextureTintPipeline.projOrtho(cx, cw + cx, cy, ch + cy, -1000, 1000);
if (color.alphaGL > 0)
{
TextureTintPipeline.drawFillRect(
cx, cy, cw, ch,
0, 0, cw + cx, ch + cy,
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1),
color.alphaGL
);
@ -1559,12 +1559,18 @@ var WebGLRenderer = new Class({
}
else if (color.alphaGL > 0)
{
this.pushScissor(cx, cy, cw, ch);
TextureTintPipeline.drawFillRect(
cx, cy, cw, ch,
0, 0, cw + cx, ch + cy,
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1),
color.alphaGL
);
}
else
{
this.pushScissor(cx, cy, cw, ch);
}
},
/**

View file

@ -733,9 +733,6 @@ var TextureTintPipeline = new Class({
var width = srcWidth;
var height = srcHeight;
// var x = -displayOriginX + frameX;
// var y = -displayOriginY + frameY;
var x = -displayOriginX;
var y = -displayOriginY;
@ -789,13 +786,6 @@ var TextureTintPipeline = new Class({
y += srcHeight;
}
// Do we need this? (doubt it)
// if (camera.roundPixels)
// {
// x |= 0;
// y |= 0;
// }
var xw = x + width;
var yh = y + height;