Allow calling love.graphics.drawLayer(arraycanvas, layer) when rendering to a different layer of the same Canvas.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-04-29 13:35:07 -03:00
parent 353852ca24
commit fd64999748
3 changed files with 21 additions and 4 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ void Canvas::draw(Graphics *gfx, Quad *q, const Matrix4 &t)
void Canvas::drawLayer(Graphics *gfx, int layer, Quad *quad, const Matrix4 &m)
{
if (gfx->isCanvasActive(this))
if (gfx->isCanvasActive(this, layer))
throw love::Exception("Cannot render a Canvas to itself!");
Texture::drawLayer(gfx, layer, quad, m);
+19 -3
View File
@@ -452,15 +452,31 @@ bool Graphics::isCanvasActive() const
bool Graphics::isCanvasActive(love::graphics::Canvas *canvas) const
{
const auto &curRTs = states.back().renderTargets;
const auto &rts = states.back().renderTargets;
for (const auto &rt : curRTs.colors)
for (const auto &rt : rts.colors)
{
if (rt.canvas.get() == canvas)
return true;
}
if (curRTs.depthStencil.canvas.get() == canvas)
if (rts.depthStencil.canvas.get() == canvas)
return true;
return false;
}
bool Graphics::isCanvasActive(Canvas *canvas, int slice) const
{
const auto &rts = states.back().renderTargets;
for (const auto &rt : rts.colors)
{
if (rt.canvas.get() == canvas && rt.slice == slice)
return true;
}
if (rts.depthStencil.canvas.get() == canvas && rts.depthStencil.slice == slice)
return true;
return false;
+1
View File
@@ -467,6 +467,7 @@ public:
RenderTargets getCanvas() const;
bool isCanvasActive() const;
bool isCanvasActive(Canvas *canvas) const;
bool isCanvasActive(Canvas *canvas, int slice) const;
/**
* Scissor defines a box such that everything outside that box is discarded