RenderTexture.fill wasn't setting the camera up before drawing the fill rect, causing it to appear in the wrong place and the wrong size. Fix #4390

This commit is contained in:
Richard Davey 2019-09-30 15:08:53 +01:00
parent 9e49d1843e
commit 487ec88529
2 changed files with 27 additions and 17 deletions

View file

@ -46,13 +46,14 @@
* `onTouchStart`, `onTouchEnd` and `onTouchMove` will now check for `event.cancelable` before calling preventDefault on the touch event, fixing issues with "Ignored attempt to cancel a touchstart event with cancelable=false, for example because scrolling is in progress and cannot be interrupted." errors in some situations. Fix #4706 (thanks @MatthewAlner)
* `MatterPhysics.shutdown` could try to access properties that may have been previously removed during the Game.destroy process, causing a console error. It now checks properties before removing events from them (thanks @nagyv)
* `ArcadePhysics.Body.hitTest` would use CircleContains to do a hit test, which assumex x/y was the Circle center, but for a Body it's the top-left, causing the hit test to be off. Fix #4748 (thanks @funnisimo)
* `ArcadePhysics.World.separateCircle` has had the velocity scaling moved to after the angle is calculated, fixing a weird collision issue when `Body.bounce=0`. Also, if both bodies are movable, they now only offset by half the offset and use the center of the body for angle calculation, allowing for any offsets to be included. Fix #4751 (thanks @funnisimo)
* `ArcadePhysics.World.separateCircle` has had the velocity scaling moved to after the angle is calculated, fixing a weird collision issue when `Body.bounce=0`. Also, if both bodies are movable, they now only offset by half the offset and use the center of the body for angle calculation, allowing for any offsets to be included. Fix #4751 (thanks @funnisimo @hizzd)
* `Tween.updateTo` would break out of the TweenData iteration as soon as it adjusted the first matching key, causing tweens acting on multiple targets to only update the first target. It now updates them all. Fix #4763 (thanks @RBrNx)
* The Container WebGLRenderer will now handle child mask batching properly, based on the renderers current mask.
* The Container WebGLRenderer will now handle child new type switching, allowing you to carry on with a batch of same-type Game Objects even if they're nested within Containers. Fix #4710 (thanks @nalgorry)
* `MultiAtlasFiles` that loaded their own external images would obtain incorrect path and URL values if the path had been changed by another file in the queue. They now retain the loader state and apply it to all child files during load.
* If more than one `MultiAtlasFile` used the same internal file name for its images, subsequent multi-atlases would fail to load. Fix #4330 (thanks @giviz)
* `MultiAtlasFiles` would incorrectly add the atlas JSON into the JSON cache, causing you to not be able to destroy and reload the texture using the same atlas key as before. Fix #4720 (thanks @giviz)
* `RenderTexture.fill` wasn't setting the camera up before drawing the fill rect, causing it to appear in the wrong place and the wrong size. Fix #4390 (thanks @Jerenaux)
### Examples, Documentation and TypeScript

View file

@ -517,38 +517,47 @@ var RenderTexture = new Class({
var gl = this.gl;
var frame = this.frame;
this.camera.preRender(1, 1);
if (gl)
{
var renderer = this.renderer;
var bounds = this.getBounds();
var cx = this.camera._cx;
var cy = this.camera._cy;
var cw = this.camera._cw;
var ch = this.camera._ch;
renderer.setFramebuffer(this.framebuffer, true);
this.renderer.setFramebuffer(this.framebuffer, false);
if (width !== frame.source.width || height !== frame.source.height)
{
gl.scissor(x + frame.cutX, y + frame.cutY, width, height);
}
this.renderer.pushScissor(cx, cy, cw, ch, ch);
this.pipeline.drawFillRect(
bounds.x, bounds.y, bounds.right, bounds.bottom,
var pipeline = this.pipeline;
pipeline.projOrtho(0, this.texture.width, 0, this.texture.height, -1000.0, 1000.0);
pipeline.drawFillRect(
x, y, width, height,
Utils.getTintFromFloats(r / 255, g / 255, b / 255, 1),
alpha
);
if (width !== frame.source.width || height !== frame.source.height)
{
gl.scissor(0, 0, frame.source.width, frame.source.height);
}
this.renderer.setFramebuffer(null, true);
this.renderer.setFramebuffer(null, false);
this.renderer.popScissor();
pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0);
}
else
{
this.renderer.setContext(this.context);
this.context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + alpha + ')';
this.context.fillRect(x + frame.cutX, y + frame.cutY, width, height);
this.renderer.setContext();
}
this.dirty = true;
return this;
},