mirror of https://github.com/bjornbytes/lovr.git
World;
This commit is contained in:
parent
7597e71ff3
commit
70bc90154b
|
@ -31,6 +31,7 @@ extern const luaL_Reg lovrSource[];
|
|||
extern const luaL_Reg lovrTexture[];
|
||||
extern const luaL_Reg lovrTimer[];
|
||||
extern const luaL_Reg lovrTransform[];
|
||||
extern const luaL_Reg lovrWorld[];
|
||||
|
||||
extern map_int_t BlendAlphaModes;
|
||||
extern map_int_t BlendModes;
|
||||
|
|
|
@ -4,10 +4,17 @@
|
|||
int l_lovrPhysicsInit(lua_State* L) {
|
||||
lua_newtable(L);
|
||||
luaL_register(L, NULL, lovrPhysics);
|
||||
luax_registertype(L, "World", lovrWorld);
|
||||
lovrPhysicsInit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrPhysicsNewWorld(lua_State* L) {
|
||||
luax_pushtype(L, World, lovrWorldCreate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrPhysics[] = {
|
||||
{ "newWorld", l_lovrPhysicsNewWorld },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#include "api/lovr.h"
|
||||
#include "physics/physics.h"
|
||||
|
||||
const luaL_Reg lovrWorld[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -14,3 +14,18 @@ void lovrPhysicsInit() {
|
|||
void lovrPhysicsDestroy() {
|
||||
dCloseODE();
|
||||
}
|
||||
|
||||
World* lovrWorldCreate() {
|
||||
World* world = lovrAlloc(sizeof(World), lovrWorldDestroy);
|
||||
if (!world) return NULL;
|
||||
|
||||
world->id = dWorldCreate();
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
void lovrWorldDestroy(const Ref* ref) {
|
||||
World* world = containerof(ref, World);
|
||||
dWorldDestroy(world->id);
|
||||
free(world);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
#include "util.h"
|
||||
#include <ode/ode.h>
|
||||
|
||||
typedef struct {
|
||||
Ref ref;
|
||||
dWorldID id;
|
||||
} World;
|
||||
|
||||
void lovrPhysicsInit();
|
||||
void lovrPhysicsDestroy();
|
||||
|
||||
World* lovrWorldCreate();
|
||||
void lovrWorldDestroy(const Ref* ref);
|
||||
|
|
Loading…
Reference in New Issue