mirror of https://github.com/bjornbytes/lovr.git
lovrPlatform: init/destroy;
This commit is contained in:
parent
b7deda3758
commit
c9793eae49
13
src/main.c
13
src/main.c
|
@ -1,5 +1,4 @@
|
|||
#include "resources/boot.lua.h"
|
||||
#include "lib/glfw.h"
|
||||
#include "version.h"
|
||||
#include "api.h"
|
||||
#include "luax.h"
|
||||
|
@ -53,7 +52,7 @@ int main(int argc, char** argv) {
|
|||
#endif
|
||||
} while (restart);
|
||||
|
||||
glfwTerminate();
|
||||
lovrPlatformDestroy();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -96,26 +95,20 @@ static void emscriptenLoop(void* arg) {
|
|||
if (restart) {
|
||||
main(context->argc, context->argv);
|
||||
} else {
|
||||
glfwTerminate();
|
||||
lovrPlatformDestroy();
|
||||
exit(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void onGlfwError(int code, const char* description) {
|
||||
lovrThrow(description);
|
||||
}
|
||||
|
||||
typedef enum { // What flag is being searched for?
|
||||
ARGFLAG_NONE, // Not processing a flag
|
||||
ARGFLAG_ROOT
|
||||
} ArgFlag;
|
||||
|
||||
lua_State* lovrInit(lua_State* L, int argc, char** argv) {
|
||||
glfwSetErrorCallback(onGlfwError);
|
||||
lovrAssert(glfwInit(), "Error initializing GLFW");
|
||||
lovrPlatformSetTime(0.);
|
||||
lovrAssert(lovrPlatformInit(), "Failed to initialize platform");
|
||||
|
||||
// arg table
|
||||
// Args follow the lua standard https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter
|
||||
|
|
|
@ -68,6 +68,8 @@ typedef void (*gpuProc)(void);
|
|||
typedef gpuProc (*getProcAddressProc)(const char*);
|
||||
extern getProcAddressProc lovrGetProcAddress;
|
||||
|
||||
bool lovrPlatformInit();
|
||||
void lovrPlatformDestroy();
|
||||
void lovrPlatformPollEvents();
|
||||
double lovrPlatformGetTime();
|
||||
void lovrPlatformSetTime(double t);
|
||||
|
|
|
@ -57,6 +57,19 @@ static int convertKeyCode(KeyCode key) {
|
|||
}
|
||||
}
|
||||
|
||||
static void onGlfwError(int code, const char* description) {
|
||||
lovrThrow(description);
|
||||
}
|
||||
|
||||
bool lovrPlatformInit() {
|
||||
glfwSetErrorCallback(onGlfwError);
|
||||
return glfwInit();
|
||||
}
|
||||
|
||||
void lovrPlatformDestroy() {
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
void lovrPlatformPollEvents() {
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue