mirror of https://github.com/bjornbytes/lovr.git
lovr.timer;
This commit is contained in:
parent
7b4fca857e
commit
aea0173cb7
|
@ -3,11 +3,12 @@ CFLAGS += -Wall
|
|||
|
||||
LIBS += -l luajit-5.1
|
||||
LIBS += -l glfw3
|
||||
LIBS += -l gl-matrix
|
||||
LIBS += -l assimp
|
||||
LIBS += -l osvrClient
|
||||
LIBS += -l osvrClientKit
|
||||
LIBS += -framework OpenGL
|
||||
LIBS += -pagezero_size 10000 -image_base 100000000 # OSX magic
|
||||
LIBS += -pagezero_size 10000 -image_base 100000000 # OSX magic for LuaJIT
|
||||
|
||||
: foreach *.c |> clang -c %f -o %o $(CFLAGS) |> obj/%B.o
|
||||
: obj/*.o |> clang -o %o %f $(LIBS) |> ../lovr
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "event.h"
|
||||
#include "lovr.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "glfw.h"
|
||||
#include <osvr/ClientKit/ContextC.h>
|
||||
#include <osvr/ClientKit/InterfaceC.h>
|
||||
#include <osvr/ClientKit/InterfaceStateC.h>
|
||||
|
@ -10,7 +10,10 @@ extern OSVR_ClientContext ctx;
|
|||
|
||||
int lovrEventPoll(lua_State* L) {
|
||||
glfwPollEvents();
|
||||
osvrClientUpdate(ctx);
|
||||
|
||||
if (osvrClientCheckStatus(ctx) != OSVR_RETURN_FAILURE) {
|
||||
osvrClientUpdate(ctx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -32,4 +32,6 @@ void initGlfw(GLFWerrorfun onError, GLFWwindowclosefun onClose) {
|
|||
error("Geez your OpenGL is old");
|
||||
}
|
||||
#endif
|
||||
|
||||
glfwSetTime(0);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "event.h"
|
||||
#include "device.h"
|
||||
#include "graphics.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include "model.h"
|
||||
#include "buffer.h"
|
||||
|
@ -20,8 +21,8 @@ void lovrInit(lua_State* L) {
|
|||
// Register modules
|
||||
luaRegisterModule(L, "event", lovrEvent);
|
||||
luaRegisterModule(L, "device", lovrDevice);
|
||||
luaRegisterModule(L, "interface", lovrInterface);
|
||||
luaRegisterModule(L, "graphics", lovrGraphics);
|
||||
luaRegisterModule(L, "timer", lovrTimer);
|
||||
|
||||
// Register types
|
||||
luaRegisterType(L, "Model", lovrModel);
|
||||
|
@ -35,7 +36,8 @@ void lovrInit(lua_State* L) {
|
|||
" if lovr.load then lovr.load() end "
|
||||
" while true do "
|
||||
" lovr.event.poll() "
|
||||
" if lovr.update then lovr.update() end "
|
||||
" local dt = lovr.timer.step() "
|
||||
" if lovr.update then lovr.update(dt) end "
|
||||
" lovr.graphics.clear() "
|
||||
" if lovr.draw then lovr.draw() end "
|
||||
" lovr.graphics.present() "
|
||||
|
|
|
@ -21,10 +21,6 @@ int main(int argc, char* argv[]) {
|
|||
initGlfw(lovrOnError, lovrOnClose);
|
||||
lovrInit(L);
|
||||
|
||||
if (osvrClientCheckStatus(ctx)) {
|
||||
osvrClientShutdown(ctx);
|
||||
}
|
||||
|
||||
lovrRun(L);
|
||||
|
||||
exit(0);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#include "timer.h"
|
||||
#include "lovr.h"
|
||||
#include "glfw.h"
|
||||
|
||||
int lovrTimerStep(lua_State* L) {
|
||||
lua_pushnumber(L, glfwGetTime());
|
||||
glfwSetTime(0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrTimer[] = {
|
||||
{ "step", lovrTimerStep },
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
|
||||
int lovrTimerStep(lua_State* L);
|
||||
|
||||
extern const luaL_Reg lovrTimer[];
|
Loading…
Reference in New Issue