mirror of https://github.com/bjornbytes/lovr.git
Fix minor issues with Texture:clear bindings;
This commit is contained in:
parent
5b6d882475
commit
bfbde95bb2
|
@ -469,6 +469,7 @@ void luax_readcolor(lua_State* L, int index, float color[4]) {
|
|||
// Like readcolor, but only consumes 1 argument (nil, hex, table, vec3, vec4), useful for table keys
|
||||
void luax_optcolor(lua_State* L, int index, float color[4]) {
|
||||
switch (lua_type(L, index)) {
|
||||
case LUA_TNONE:
|
||||
case LUA_TNIL:
|
||||
color[0] = color[1] = color[2] = color[3] = 1.f;
|
||||
break;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "util.h"
|
||||
#include "graphics/graphics.h"
|
||||
#include "data/image.h"
|
||||
#include <string.h>
|
||||
|
||||
static int l_lovrTextureNewView(lua_State* L) {
|
||||
Texture* texture = luax_checktype(L, 1, Texture);
|
||||
|
@ -202,12 +203,24 @@ static int l_lovrTextureSetPixels(lua_State* L) {
|
|||
|
||||
static int l_lovrTextureClear(lua_State* L) {
|
||||
Texture* texture = luax_totype(L, 1, Texture);
|
||||
|
||||
int index;
|
||||
float value[4];
|
||||
if (lua_isnoneornil(L, 2)) {
|
||||
memset(value, 0, sizeof(value));
|
||||
index = 3;
|
||||
} else if (lua_type(L, 2) == LUA_TNUMBER && lua_gettop(L) > 2) {
|
||||
luax_readcolor(L, 2, value);
|
||||
index = 6;
|
||||
} else {
|
||||
luax_optcolor(L, 2, value);
|
||||
uint32_t layer = luax_optu32(L, 3, 1) - 1;
|
||||
uint32_t layerCount = luax_optu32(L, 4, ~0u);
|
||||
uint32_t level = luax_optu32(L, 5, 1) - 1;
|
||||
uint32_t levelCount = luax_optu32(L, 6, ~0u);
|
||||
index = 3;
|
||||
}
|
||||
|
||||
uint32_t layer = luax_optu32(L, index++, 1) - 1;
|
||||
uint32_t layerCount = luax_optu32(L, index++, ~0u);
|
||||
uint32_t level = luax_optu32(L, index++, 1) - 1;
|
||||
uint32_t levelCount = luax_optu32(L, index++, ~0u);
|
||||
lovrTextureClear(texture, value, layer, layerCount, level, levelCount);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue