Add mipmapping support to Canvases.

- Added an optional mipmap index argument to the non-table variant of love.graphics.setCanvas, and an optional ‘mipmap’ field to the table variant.
- Canvas:setMipmapFilter now works.
- Added Canvas:generateMipmaps.
- Added Canvas:getMipmapMode.
- Added a new ‘mipmaps’ enum field to the table passed into love.graphics.newCanvas. Accepted values are “none” (default), “manual”, and “auto”.

If a Canvas has the manual mipmap mode, you will either need to render to a mipmap level or call Canvas:generateMipmaps. If it has the auto mode, mipmaps will be automatically generated after rendering to that Canvas. Generating mipmaps is not free.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-04-15 01:58:03 -03:00
parent a0ef2ac28b
commit 7161d600b7
16 changed files with 396 additions and 201 deletions
+7 -6
View File
@@ -301,7 +301,7 @@ void Graphics::restoreStateChecked(const DisplayState &s)
{
const auto &rt1 = sRTs.colors[i];
const auto &rt2 = curRTs.colors[i];
if (rt1.canvas.get() != rt2.canvas.get() || rt1.slice != rt2.slice)
if (rt1.canvas.get() != rt2.canvas.get() || rt1.slice != rt2.slice || rt1.mipmap != rt2.mipmap)
{
canvaseschanged = true;
break;
@@ -309,7 +309,8 @@ void Graphics::restoreStateChecked(const DisplayState &s)
}
if (!canvaseschanged && (sRTs.depthStencil.canvas.get() != curRTs.depthStencil.canvas.get()
|| sRTs.depthStencil.slice != curRTs.depthStencil.slice))
|| sRTs.depthStencil.slice != curRTs.depthStencil.slice
|| sRTs.depthStencil.mipmap != curRTs.depthStencil.mipmap))
{
canvaseschanged = true;
}
@@ -422,9 +423,9 @@ void Graphics::setCanvas(const RenderTargetsStrongRef &rts)
targets.colors.reserve(rts.colors.size());
for (const auto &rt : rts.colors)
targets.colors.emplace_back(rt.canvas.get(), rt.slice);
targets.colors.emplace_back(rt.canvas.get(), rt.slice, rt.mipmap);
targets.depthStencil = RenderTarget(rts.depthStencil.canvas, rts.depthStencil.slice);
targets.depthStencil = RenderTarget(rts.depthStencil.canvas, rts.depthStencil.slice, rts.depthStencil.mipmap);
return setCanvas(targets);
}
@@ -437,9 +438,9 @@ Graphics::RenderTargets Graphics::getCanvas() const
rts.colors.reserve(curRTs.colors.size());
for (const auto &rt : curRTs.colors)
rts.colors.emplace_back(rt.canvas.get(), rt.slice);
rts.colors.emplace_back(rt.canvas.get(), rt.slice, rt.mipmap);
rts.depthStencil = RenderTarget(curRTs.depthStencil.canvas, curRTs.depthStencil.slice);
rts.depthStencil = RenderTarget(curRTs.depthStencil.canvas, curRTs.depthStencil.slice, curRTs.depthStencil.mipmap);
return rts;
}