mirror of https://github.com/bjornbytes/lovr.git
Buffer:clear and Pass:clear(Buffer) use the same units;
This commit is contained in:
parent
08f0ca7434
commit
a796c92556
|
@ -173,7 +173,7 @@ void luax_readbufferdata(lua_State* L, int index, Buffer* buffer, char* data) {
|
|||
|
||||
uint32_t length = luax_len(L, index);
|
||||
uint32_t limit = nested ? MIN(length - srcIndex, info->length - dstIndex) : info->length - dstIndex;
|
||||
uint32_t count = luaL_optinteger(L, index + 3, limit);
|
||||
uint32_t count = luax_optu32(L, index + 3, limit);
|
||||
lovrCheck(dstIndex + count <= info->length, "Tried to write Buffer elements [%d,%d] but Buffer can only hold %d things", dstIndex + 1, dstIndex + count - 1, info->length);
|
||||
|
||||
data = data ? data : lovrBufferMap(buffer, dstIndex * stride, count * stride);
|
||||
|
@ -290,8 +290,8 @@ static int l_lovrBufferSetData(lua_State* L) {
|
|||
static int l_lovrBufferClear(lua_State* L) {
|
||||
Buffer* buffer = luax_checkbuffer(L, 1);
|
||||
const BufferInfo* info = lovrBufferGetInfo(buffer);
|
||||
uint32_t index = luaL_optinteger(L, 2, 1);
|
||||
uint32_t count = luaL_optinteger(L, 3, info->length - index + 1);
|
||||
uint32_t index = luax_optu32(L, 2, 1);
|
||||
uint32_t count = luax_optu32(L, 3, info->length - index + 1);
|
||||
lovrBufferClear(buffer, (index - 1) * info->stride, count * info->stride);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -797,9 +797,10 @@ static int l_lovrPassClear(lua_State* L) {
|
|||
Buffer* buffer = luax_totype(L, 2, Buffer);
|
||||
|
||||
if (buffer) {
|
||||
uint32_t offset = luax_optu32(L, 3, 0);
|
||||
uint32_t extent = luax_optu32(L, 4, ~0u);
|
||||
lovrPassClearBuffer(pass, buffer, offset, extent);
|
||||
const BufferInfo* info = lovrBufferGetInfo(buffer);
|
||||
uint32_t index = luax_optu32(L, 3, 1);
|
||||
uint32_t count = luax_optu32(L, 4, info->length - index + 1);
|
||||
lovrBufferClear(buffer, (index - 1) * info->stride, count * info->stride);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue