mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-03 21:13:42 +00:00
rm drawInstanced (last argument of draw instead);
Willing to revert this, but I think this is the cleaner API to use.
This commit is contained in:
parent
259dbd5758
commit
2435108d4d
|
@ -71,11 +71,11 @@ int l_lovrMeshDetachAttributes(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrMeshDrawInstanced(lua_State* L) {
|
int l_lovrMeshDraw(lua_State* L) {
|
||||||
Mesh* mesh = luax_checktype(L, 1, Mesh);
|
Mesh* mesh = luax_checktype(L, 1, Mesh);
|
||||||
int instances = luaL_checkinteger(L, 2);
|
|
||||||
float transform[16];
|
float transform[16];
|
||||||
luax_readmat4(L, 3, transform, 1, NULL);
|
int index = luax_readmat4(L, 3, transform, 1, NULL);
|
||||||
|
int instances = luaL_optinteger(L, index, 1);
|
||||||
lovrGraphicsDraw(&(DrawCommand) {
|
lovrGraphicsDraw(&(DrawCommand) {
|
||||||
.transform = transform,
|
.transform = transform,
|
||||||
.mesh = mesh,
|
.mesh = mesh,
|
||||||
|
@ -85,12 +85,6 @@ int l_lovrMeshDrawInstanced(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrMeshDraw(lua_State* L) {
|
|
||||||
lua_pushinteger(L, 1);
|
|
||||||
lua_insert(L, 2);
|
|
||||||
return l_lovrMeshDrawInstanced(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
int l_lovrMeshGetDrawMode(lua_State* L) {
|
int l_lovrMeshGetDrawMode(lua_State* L) {
|
||||||
Mesh* mesh = luax_checktype(L, 1, Mesh);
|
Mesh* mesh = luax_checktype(L, 1, Mesh);
|
||||||
lua_pushstring(L, MeshDrawModes[lovrMeshGetDrawMode(mesh)]);
|
lua_pushstring(L, MeshDrawModes[lovrMeshGetDrawMode(mesh)]);
|
||||||
|
@ -346,7 +340,6 @@ int l_lovrMeshSetMaterial(lua_State* L) {
|
||||||
const luaL_Reg lovrMesh[] = {
|
const luaL_Reg lovrMesh[] = {
|
||||||
{ "attachAttributes", l_lovrMeshAttachAttributes },
|
{ "attachAttributes", l_lovrMeshAttachAttributes },
|
||||||
{ "detachAttributes", l_lovrMeshDetachAttributes },
|
{ "detachAttributes", l_lovrMeshDetachAttributes },
|
||||||
{ "drawInstanced", l_lovrMeshDrawInstanced },
|
|
||||||
{ "draw", l_lovrMeshDraw },
|
{ "draw", l_lovrMeshDraw },
|
||||||
{ "getVertexFormat", l_lovrMeshGetVertexFormat },
|
{ "getVertexFormat", l_lovrMeshGetVertexFormat },
|
||||||
{ "getVertexCount", l_lovrMeshGetVertexCount },
|
{ "getVertexCount", l_lovrMeshGetVertexCount },
|
||||||
|
|
|
@ -2,21 +2,15 @@
|
||||||
#include "api/math.h"
|
#include "api/math.h"
|
||||||
#include "graphics/model.h"
|
#include "graphics/model.h"
|
||||||
|
|
||||||
int l_lovrModelDrawInstanced(lua_State* L) {
|
int l_lovrModelDraw(lua_State* L) {
|
||||||
Model* model = luax_checktype(L, 1, Model);
|
Model* model = luax_checktype(L, 1, Model);
|
||||||
int instances = luaL_checkinteger(L, 2);
|
|
||||||
float transform[16];
|
float transform[16];
|
||||||
luax_readmat4(L, 3, transform, 1, NULL);
|
int index = luax_readmat4(L, 3, transform, 1, NULL);
|
||||||
|
int instances = luaL_optinteger(L, index, 1);
|
||||||
lovrModelDraw(model, transform, instances);
|
lovrModelDraw(model, transform, instances);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrModelDraw(lua_State* L) {
|
|
||||||
lua_pushinteger(L, 1);
|
|
||||||
lua_insert(L, 2);
|
|
||||||
return l_lovrModelDrawInstanced(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
int l_lovrModelGetAABB(lua_State* L) {
|
int l_lovrModelGetAABB(lua_State* L) {
|
||||||
Model* model = luax_checktype(L, 1, Model);
|
Model* model = luax_checktype(L, 1, Model);
|
||||||
const float* aabb = lovrModelGetAABB(model);
|
const float* aabb = lovrModelGetAABB(model);
|
||||||
|
@ -80,7 +74,6 @@ int l_lovrModelGetMesh(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const luaL_Reg lovrModel[] = {
|
const luaL_Reg lovrModel[] = {
|
||||||
{ "drawInstanced", l_lovrModelDrawInstanced },
|
|
||||||
{ "draw", l_lovrModelDraw },
|
{ "draw", l_lovrModelDraw },
|
||||||
{ "getAABB", l_lovrModelGetAABB },
|
{ "getAABB", l_lovrModelGetAABB },
|
||||||
{ "getAnimator", l_lovrModelGetAnimator },
|
{ "getAnimator", l_lovrModelGetAnimator },
|
||||||
|
|
Loading…
Reference in a new issue