mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Add Buffer:clear, to reset all or part of a Buffer's contents to 0.
This commit is contained in:
@@ -254,6 +254,20 @@ void Buffer::unmap(size_t usedoffset, size_t usedsize)
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::clear(size_t offset, size_t size)
|
||||
{
|
||||
if (isImmutable())
|
||||
throw love::Exception("Cannot clear an immutable Buffer.");
|
||||
else if (isMapped())
|
||||
throw love::Exception("Cannot clear a mapped Buffer.");
|
||||
else if (offset + size > getSize())
|
||||
throw love::Exception("The given offset and size parameters to clear() are not within the Buffer's size.");
|
||||
else if (offset % 4 != 0 || size % 4 != 0)
|
||||
throw love::Exception("clear() must be used with offset and size parameters that are multiples of 4 bytes.");
|
||||
|
||||
vkCmdFillBuffer(vgfx->getCommandBufferForDataTransfer(), buffer, offset, size, 0);
|
||||
}
|
||||
|
||||
void Buffer::copyTo(love::graphics::Buffer *dest, size_t sourceoffset, size_t destoffset, size_t size)
|
||||
{
|
||||
auto commandBuffer = vgfx->getCommandBufferForDataTransfer();
|
||||
|
||||
Reference in New Issue
Block a user