Add love.graphics.getQuadIndexBuffer.

love's pre-generated quad index buffer is useful when combined with drawShaderVertices. Note that it uses 16 bit indices so it can only draw up to 16k quads in a single call.
This commit is contained in:
Alex Szpakowski
2022-01-03 16:22:08 -04:00
parent 42e8df1489
commit ecbc5ca7f6
6 changed files with 25 additions and 2 deletions
+8
View File
@@ -182,6 +182,8 @@ void Graphics::createQuadIndexBuffer()
Buffer::Mapper map(*quadIndexBuffer);
fillIndices(TRIANGLEINDEX_QUADS, 0, LOVE_UINT16_MAX, (uint16 *) map.data);
quadIndexBuffer->setImmutable(true);
}
Quad *Graphics::newQuad(Quad::Viewport v, double sw, double sh)
@@ -1073,6 +1075,9 @@ void Graphics::copyBuffer(Buffer *source, Buffer *dest, size_t sourceoffset, siz
if (source == dest && sourcerange.intersects(destrange))
throw love::Exception("Copying a portion of a buffer to the same buffer requires non-overlapping source and destination offsets.");
if (dest->isImmutable())
throw love::Exception("Cannot copy to an immutable buffer.");
source->copyTo(dest, sourceoffset, destoffset, size);
}
@@ -1098,6 +1103,9 @@ void Graphics::copyTextureToBuffer(Texture *source, Buffer *dest, int slice, int
if (dest->getDataUsage() == BUFFERDATAUSAGE_STREAM)
throw love::Exception("Buffers created with 'stream' data usage cannot be used as a copy destination.");
if (dest->isImmutable())
throw love::Exception("Cannot copy to an immutable buffer.");
if (isRenderTargetActive(source))
throw love::Exception("copyTextureToBuffer cannot be called while the Texture is an active render target.");