1 | // |
---|
2 | // Lol Engine |
---|
3 | // |
---|
4 | // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> |
---|
5 | // This program is free software; you can redistribute it and/or |
---|
6 | // modify it under the terms of the Do What The Fuck You Want To |
---|
7 | // Public License, Version 2, as published by Sam Hocevar. See |
---|
8 | // http://www.wtfpl.net/ for more details. |
---|
9 | // |
---|
10 | |
---|
11 | #if defined HAVE_CONFIG_H |
---|
12 | # include "config.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include "core.h" |
---|
16 | #include "lolgl.h" |
---|
17 | |
---|
18 | #if defined __CELLOS_LV2__ |
---|
19 | # include "platform/ps3/ps3app.h" |
---|
20 | #elif defined _XBOX |
---|
21 | # include "platform/xbox/xboxapp.h" |
---|
22 | #elif defined __native_client__ |
---|
23 | # include "platform/nacl/nacl-app.h" |
---|
24 | #elif defined __ANDROID__ |
---|
25 | # include "platform/android/androidapp.h" |
---|
26 | #elif defined HAVE_GLES_2X |
---|
27 | # include "eglapp.h" |
---|
28 | #else |
---|
29 | # include "platform/sdl/sdlapp.h" |
---|
30 | # include "platform/sdl/sdlinput.h" |
---|
31 | #endif |
---|
32 | |
---|
33 | using namespace std; |
---|
34 | |
---|
35 | namespace lol |
---|
36 | { |
---|
37 | |
---|
38 | class ApplicationData |
---|
39 | { |
---|
40 | friend class Application; |
---|
41 | |
---|
42 | ApplicationData(char const *name, ivec2 resolution, float framerate) |
---|
43 | : app(name, resolution, framerate) |
---|
44 | { } |
---|
45 | |
---|
46 | #if defined __CELLOS_LV2__ |
---|
47 | Ps3App app; |
---|
48 | #elif defined _XBOX |
---|
49 | XboxApp app; |
---|
50 | #elif defined __native_client__ |
---|
51 | NaClApp app; |
---|
52 | #elif defined __ANDROID__ |
---|
53 | AndroidApp app; |
---|
54 | #elif defined HAVE_GLES_2X |
---|
55 | /* FIXME: this macro is only deactivated if we include "lolgl.h" */ |
---|
56 | EglApp app; |
---|
57 | #elif defined HAVE_SDL_H |
---|
58 | SdlApp app; |
---|
59 | #else |
---|
60 | # error No application class available on this platform |
---|
61 | #endif |
---|
62 | }; |
---|
63 | |
---|
64 | /* |
---|
65 | * Public Application class |
---|
66 | */ |
---|
67 | |
---|
68 | Application::Application(char const *name, ivec2 resolution, float framerate) |
---|
69 | { |
---|
70 | data = new ApplicationData(name, resolution, framerate); |
---|
71 | } |
---|
72 | |
---|
73 | bool Application::MustTick() |
---|
74 | { |
---|
75 | return !Ticker::Finished(); |
---|
76 | } |
---|
77 | |
---|
78 | void Application::Tick() |
---|
79 | { |
---|
80 | data->app.Tick(); |
---|
81 | } |
---|
82 | |
---|
83 | void Application::ShowPointer(bool show) |
---|
84 | { |
---|
85 | data->app.ShowPointer(show); |
---|
86 | } |
---|
87 | |
---|
88 | Application::~Application() |
---|
89 | { |
---|
90 | delete data; |
---|
91 | } |
---|
92 | |
---|
93 | } /* namespace lol */ |
---|
94 | |
---|