Avoid Camera generating unchanged DrawingContext.

This commit is contained in:
Ben Richards 2024-04-29 10:21:43 +12:00
parent 45a73c1d2d
commit ef4731c8b1

View file

@ -37,20 +37,24 @@ var Camera = new Class({
*/
run: function (drawingContext, children, camera, parentTransformMatrix)
{
// Generate a drawing context.
// TODO: Handle FX stacks and framebuffer changeover.
var currentContext = drawingContext.getClone();
currentContext.autoClear = 0;
// Set camera scissor.
var cx = camera.x;
var cy = camera.y;
var cw = camera.width;
var ch = camera.height;
currentContext.setScissorBox(cx, cy, cw, ch);
// Enter drawing context.
currentContext.use();
var currentContext = drawingContext;
if (camera._customViewport)
{
// Generate a drawing context.
// TODO: Handle FX stacks and framebuffer changeover.
currentContext = drawingContext.getClone();
currentContext.autoClear = 0;
// Set camera scissor.
var cx = camera.x;
var cy = camera.y;
var cw = camera.width;
var ch = camera.height;
currentContext.setScissorBox(cx, cy, cw, ch);
// Enter drawing context.
currentContext.use();
}
// Draw camera fill.
if (camera.backgroundColor.alphaGL > 0)
@ -73,7 +77,10 @@ var Camera = new Class({
// Finish rendering.
currentContext.release();
if (camera._customViewport)
{
currentContext.release();
}
camera.dirty = false;