mirror of
https://github.com/Relintai/sfw.git
synced 2024-11-08 07:52:09 +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"
|
#include "game_application.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
Application *application = memnew(GameApplication());
|
Application *application = memnew(GameApplication());
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
application->start_main_loop();
|
||||||
emscripten_set_main_loop(&Application::main_loop_static, 0, 1);
|
|
||||||
#else
|
|
||||||
while (application->running) {
|
|
||||||
application->main_loop();
|
|
||||||
}
|
|
||||||
#endif // __EMSCRIPTEN__
|
|
||||||
|
|
||||||
memdelete(application);
|
memdelete(application);
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
//--STRIP
|
//--STRIP
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#endif // __EMSCRIPTEN__
|
||||||
|
|
||||||
#include "render_core/application.h"
|
#include "render_core/application.h"
|
||||||
|
|
||||||
#include "core/math_defs.h"
|
#include "core/math_defs.h"
|
||||||
@ -30,6 +35,16 @@ void Application::render() {
|
|||||||
scene->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() {
|
void Application::main_loop() {
|
||||||
uint64_t start = STime::time_us();
|
uint64_t start = STime::time_us();
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ public:
|
|||||||
virtual void update(float delta);
|
virtual void update(float delta);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
|
|
||||||
|
void start_main_loop();
|
||||||
|
|
||||||
uint64_t get_idle_frames() const {
|
uint64_t get_idle_frames() const {
|
||||||
return _idle_frames;
|
return _idle_frames;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user