mirror of
https://github.com/Relintai/sfw.git
synced 2024-12-20 21:06:49 +01:00
Simplify main().
This commit is contained in:
parent
e21dcb59c8
commit
5b13577a54
12
sfw/main.cpp
12
sfw/main.cpp
@ -1,19 +1,9 @@
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif // __EMSCRIPTEN__
|
||||
|
||||
#include "game_application.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Application *application = memnew(GameApplication());
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(&Application::main_loop_static, 0, 1);
|
||||
#else
|
||||
while (application->running) {
|
||||
application->main_loop();
|
||||
}
|
||||
#endif // __EMSCRIPTEN__
|
||||
application->start_main_loop();
|
||||
|
||||
memdelete(application);
|
||||
|
||||
|
@ -1,4 +1,9 @@
|
||||
//--STRIP
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif // __EMSCRIPTEN__
|
||||
|
||||
#include "render_core/application.h"
|
||||
|
||||
#include "core/math_defs.h"
|
||||
@ -30,6 +35,16 @@ void Application::render() {
|
||||
scene->render();
|
||||
}
|
||||
|
||||
void Application::start_main_loop() {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(&Application::main_loop_static, 0, 1);
|
||||
#else
|
||||
while (running) {
|
||||
main_loop();
|
||||
}
|
||||
#endif // __EMSCRIPTEN__
|
||||
}
|
||||
|
||||
void Application::main_loop() {
|
||||
uint64_t start = STime::time_us();
|
||||
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
virtual void update(float delta);
|
||||
virtual void render();
|
||||
|
||||
void start_main_loop();
|
||||
|
||||
uint64_t get_idle_frames() const {
|
||||
return _idle_frames;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user