mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Fixed scissors when using a small cam with render texture
This commit is contained in:
parent
79b4f07530
commit
0b95ed0478
3 changed files with 13 additions and 15 deletions
|
@ -261,6 +261,8 @@ var Camera = new Class({
|
||||||
/**
|
/**
|
||||||
* Sets the Camera to render to a texture instead of to the main display.
|
* 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.
|
* This is an experimental feature and should be expected to change in the future.
|
||||||
*
|
*
|
||||||
* @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture
|
* @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture
|
||||||
|
|
|
@ -1530,14 +1530,14 @@ var WebGLRenderer = new Class({
|
||||||
var cw = camera._cw;
|
var cw = camera._cw;
|
||||||
var ch = camera._ch;
|
var ch = camera._ch;
|
||||||
|
|
||||||
this.pushScissor(cx, cy, cw, ch);
|
|
||||||
|
|
||||||
var TextureTintPipeline = this.pipelines.TextureTintPipeline;
|
var TextureTintPipeline = this.pipelines.TextureTintPipeline;
|
||||||
|
|
||||||
var color = camera.backgroundColor;
|
var color = camera.backgroundColor;
|
||||||
|
|
||||||
if (camera.renderToTexture)
|
if (camera.renderToTexture)
|
||||||
{
|
{
|
||||||
|
this.pushScissor(cx, cy, cw, -ch);
|
||||||
|
|
||||||
this.setFramebuffer(camera.framebuffer);
|
this.setFramebuffer(camera.framebuffer);
|
||||||
|
|
||||||
var gl = this.gl;
|
var gl = this.gl;
|
||||||
|
@ -1546,12 +1546,12 @@ var WebGLRenderer = new Class({
|
||||||
|
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
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)
|
if (color.alphaGL > 0)
|
||||||
{
|
{
|
||||||
TextureTintPipeline.drawFillRect(
|
TextureTintPipeline.drawFillRect(
|
||||||
cx, cy, cw, ch,
|
0, 0, cw + cx, ch + cy,
|
||||||
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1),
|
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1),
|
||||||
color.alphaGL
|
color.alphaGL
|
||||||
);
|
);
|
||||||
|
@ -1559,12 +1559,18 @@ var WebGLRenderer = new Class({
|
||||||
}
|
}
|
||||||
else if (color.alphaGL > 0)
|
else if (color.alphaGL > 0)
|
||||||
{
|
{
|
||||||
|
this.pushScissor(cx, cy, cw, ch);
|
||||||
|
|
||||||
TextureTintPipeline.drawFillRect(
|
TextureTintPipeline.drawFillRect(
|
||||||
cx, cy, cw, ch,
|
0, 0, cw + cx, ch + cy,
|
||||||
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1),
|
Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1),
|
||||||
color.alphaGL
|
color.alphaGL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.pushScissor(cx, cy, cw, ch);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -733,9 +733,6 @@ var TextureTintPipeline = new Class({
|
||||||
var width = srcWidth;
|
var width = srcWidth;
|
||||||
var height = srcHeight;
|
var height = srcHeight;
|
||||||
|
|
||||||
// var x = -displayOriginX + frameX;
|
|
||||||
// var y = -displayOriginY + frameY;
|
|
||||||
|
|
||||||
var x = -displayOriginX;
|
var x = -displayOriginX;
|
||||||
var y = -displayOriginY;
|
var y = -displayOriginY;
|
||||||
|
|
||||||
|
@ -789,13 +786,6 @@ var TextureTintPipeline = new Class({
|
||||||
y += srcHeight;
|
y += srcHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we need this? (doubt it)
|
|
||||||
// if (camera.roundPixels)
|
|
||||||
// {
|
|
||||||
// x |= 0;
|
|
||||||
// y |= 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
var xw = x + width;
|
var xw = x + width;
|
||||||
var yh = y + height;
|
var yh = y + height;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue