love.graphics.copyBuffer: slightly more robust error handling.

This commit is contained in:
Sasha Szpakowski
2023-02-19 19:36:32 -04:00
parent c70b0a0b03
commit 416abdbc59
+9
View File
@@ -1370,6 +1370,9 @@ void Graphics::copyBuffer(Buffer *source, Buffer *dest, size_t sourceoffset, siz
if (dest->isImmutable())
throw love::Exception("Cannot copy to an immutable buffer.");
if (sourceoffset % 4 != 0 || destoffset % 4 != 0 || size % 4 != 0)
throw love::Exception("Buffer copy source offset, destination offset, and size parameters must be multiples of 4 bytes.");
source->copyTo(dest, sourceoffset, destoffset, size);
}
@@ -1456,6 +1459,9 @@ void Graphics::copyTextureToBuffer(Texture *source, Buffer *dest, int slice, int
Range destrange(destoffset, size);
if (destoffset % 4 != 0 || size % 4 != 0)
throw love::Exception("Buffer copy destination offset and computed byte size must be multiples of 4 bytes.");
if (destrange.getMax() >= dest->getSize())
throw love::Exception("Buffer copy destination offset and width/height doesn't fit within the destination Buffer.");
@@ -1536,6 +1542,9 @@ void Graphics::copyBufferToTexture(Buffer *source, Texture *dest, size_t sourceo
Range sourcerange(sourceoffset, size);
if (sourceoffset % 4 != 0 || size % 4 != 0)
throw love::Exception("Buffer copy source offset and computed byte size must be multiples of 4 bytes.");
if (sourcerange.getMax() >= source->getSize())
throw love::Exception("Buffer copy source offset and width/height doesn't fit within the source Buffer.");