sfw/main.cpp

48 lines
782 B
C++
Raw Normal View History

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif // __EMSCRIPTEN__
#include "application.h"
2023-12-19 15:23:49 +01:00
#include "window.h"
#include "game_application.h"
2023-12-19 15:57:36 +01:00
#include "window.h"
Application *application = NULL;
void handle_frame() {
2023-12-19 15:23:49 +01:00
application->main_loop();
}
2023-12-19 15:23:49 +01:00
int main(int argc, char **argv) {
2023-12-19 15:57:36 +01:00
AppWindow *w = memnew(AppWindow());
w->create(100, 0);
2023-12-19 15:23:49 +01:00
application = new GameApplication();
2023-12-19 15:23:49 +01:00
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(handle_frame, 0, 1);
#else
//while (application->running) {
// application->main_loop();
//}
2023-12-19 15:23:49 +01:00
while (application->running) {
if (w->frame_begin()) {
//w->resize();
//w->render_callback(loopArg);
w->frame_end();
w->frame_swap();
} else {
w->shutdown();
}
}
2023-12-19 15:23:49 +01:00
delete application;
#endif // __EMSCRIPTEN__
2023-12-19 15:23:49 +01:00
return 0;
}