-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapplication.cpp
More file actions
62 lines (53 loc) · 1.12 KB
/
application.cpp
File metadata and controls
62 lines (53 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <fea/structure/application.hpp>
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif
namespace fea
{
#ifdef EMSCRIPTEN
static Application* instance = nullptr;
void trampoline()
{
if(instance != nullptr)
{
if(!instance->shuttingDown())
instance->loop();
else
{
instance = nullptr;
emscripten_cancel_main_loop();
}
}
}
#endif
Application::Application() : mShutDown(false)
{
}
void Application::run(int argc, char** argv)
{
std::vector<std::string> args;
for(int i = 0; i < argc; ++i)
{
args.push_back(std::string(argv[i]));
}
setup(args);
#ifdef EMSCRIPTEN
instance = this;
emscripten_set_main_loop(trampoline, 0, true);
#else
while(!mShutDown)
loop();
#endif
}
void Application::quit()
{
mShutDown = true;
}
bool Application::shuttingDown()
{
return mShutDown;
}
void Application::setup(const std::vector<std::string>& args)
{
}
}