mirror of
https://github.com/love2d/love.git
synced 2026-08-20 12:40:20 +02:00
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:
@@ -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)
|
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!");
|
throw love::Exception("Cannot render a Canvas to itself!");
|
||||||
|
|
||||||
Texture::drawLayer(gfx, layer, quad, m);
|
Texture::drawLayer(gfx, layer, quad, m);
|
||||||
|
|||||||
@@ -452,15 +452,31 @@ bool Graphics::isCanvasActive() const
|
|||||||
|
|
||||||
bool Graphics::isCanvasActive(love::graphics::Canvas *canvas) 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)
|
if (rt.canvas.get() == canvas)
|
||||||
return true;
|
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 true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -467,6 +467,7 @@ public:
|
|||||||
RenderTargets getCanvas() const;
|
RenderTargets getCanvas() const;
|
||||||
bool isCanvasActive() const;
|
bool isCanvasActive() const;
|
||||||
bool isCanvasActive(Canvas *canvas) 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
|
* Scissor defines a box such that everything outside that box is discarded
|
||||||
|
|||||||
Reference in New Issue
Block a user