Add optional ‘readable’ boolean field to the table passed into love.graphics.newCanvas. Added new variant of love.graphics.getCanvasFormats which takes a ‘readable’ boolean.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-04-11 19:03:13 -03:00
parent c36a53fdcb
commit 43172bd3f6
8 changed files with 83 additions and 13 deletions
+12 -6
View File
@@ -165,7 +165,11 @@ Canvas::Canvas(const Settings &settings)
throw love::Exception("MSAA is only supported for Canvases with the 2D texture type.");
format = getSizedFormat(settings.format);
readable = !isPixelFormatDepthStencil(format);
if (settings.readable.set)
readable = settings.readable.value;
else
readable = !isPixelFormatDepthStencil(format);
initQuad();
loadVolatile();
@@ -187,7 +191,7 @@ bool Canvas::loadVolatile()
if (!Canvas::isSupported())
throw love::Exception("Canvases are not supported by your OpenGL drivers!");
if (!Canvas::isFormatSupported(format))
if (!Canvas::isFormatSupported(format, readable))
{
const char *fstr = "rgba8";
love::getConstant(Canvas::getSizedFormat(format), fstr);
@@ -488,6 +492,11 @@ Canvas::SupportedFormat Canvas::supportedFormats[] = {};
Canvas::SupportedFormat Canvas::checkedFormats[] = {};
bool Canvas::isFormatSupported(PixelFormat format)
{
return isFormatSupported(format, !isPixelFormatDepthStencil(format));
}
bool Canvas::isFormatSupported(PixelFormat format, bool readable)
{
if (!isSupported())
return false;
@@ -498,9 +507,6 @@ bool Canvas::isFormatSupported(PixelFormat format)
bool supported = true;
format = getSizedFormat(format);
bool depthstencil = isPixelFormatDepthStencil(format);
bool readable = !depthstencil;
if (!OpenGL::isPixelFormatSupported(format, true, readable, false))
return false;
@@ -525,7 +531,7 @@ bool Canvas::isFormatSupported(PixelFormat format)
// Make sure at least something is bound to a color attachment. I believe
// this is required on ES2 but I'm not positive.
if (depthstencil)
if (isPixelFormatDepthStencil(format))
gl.framebufferTexture(GL_COLOR_ATTACHMENT0, TEXTURE_2D, gl.getDefaultTexture(TEXTURE_2D), 0, 0, 0);
if (readable)