disallow texture:replacePixels and non-canvas textures for depth/stencil pixel formats.

This commit is contained in:
Sasha Szpakowski
2024-07-15 17:55:31 -03:00
parent bb5cea6d7d
commit 906f615a9e
2 changed files with 17 additions and 5 deletions
+6
View File
@@ -284,6 +284,9 @@ Texture::Texture(Graphics *gfx, const Settings &settings, const Slices *slices)
if (isCompressed() && renderTarget)
throw love::Exception("Compressed textures cannot be render targets.");
if (isPixelFormatDepthStencil(format) && !renderTarget)
throw love::Exception("Depth or stencil pixel formats are only supported with render target textures.");
for (PixelFormat viewformat : viewFormats)
{
if (getLinearPixelFormat(viewformat) == getLinearPixelFormat(format))
@@ -582,6 +585,9 @@ void Texture::replacePixels(love::image::ImageDataBase *d, int slice, int mipmap
if (getMSAA() > 1)
throw love::Exception("replacePixels cannot be called on a MSAA Texture.");
if (isPixelFormatDepthStencil(format))
throw love::Exception("replacePixels cannot be called on depth or stencil Textures.");
auto gfx = Module::getInstance<Graphics>(Module::M_GRAPHICS);
if (gfx != nullptr && gfx->isRenderTargetActive(this))
throw love::Exception("replacePixels cannot be called on this Texture while it's an active render target.");