Add texture/color variants to lovr.graphics.newMaterial;

This commit is contained in:
bjorn 2017-11-23 14:41:22 -08:00
parent 4fb72d8cb9
commit 2b88d51ff8
1 changed files with 13 additions and 0 deletions

View File

@ -683,6 +683,19 @@ int l_lovrGraphicsNewFont(lua_State* L) {
int l_lovrGraphicsNewMaterial(lua_State* L) {
MaterialData* materialData = lovrMaterialDataCreateEmpty();
Material* material = lovrMaterialCreate(materialData, false);
int index = 1;
if (lua_isuserdata(L, index)) {
Texture* texture = luax_checktype(L, index++, Texture);
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
}
if (lua_isnumber(L, index)) {
Color color = luax_checkcolor(L, index);
lovrMaterialSetColor(material, COLOR_DIFFUSE, color);
}
luax_pushtype(L, Material, material);
return 1;
}