source: trunk/src/application/application.cpp @ 2565

Last change on this file since 2565 was 2565, checked in by sam, 8 years ago

lua: add support for lua/init.lua in a global World object and give
it a try in MrPigeon.

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
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
17#include "lolgl.h"
18
19#if defined __CELLOS_LV2__
20#   include "platform/ps3/ps3app.h"
21#elif defined _XBOX
22#   include "platform/xbox/xboxapp.h"
23#elif defined __native_client__
24#   include "platform/nacl/nacl-app.h"
25#elif defined __ANDROID__
26#   include "platform/android/androidapp.h"
27#elif defined HAVE_GLES_2X
28#   include "eglapp.h"
29#else
30#   include "platform/sdl/sdlapp.h"
31#   include "platform/sdl/sdlinput.h"
32#endif
33
34using namespace std;
35
36namespace lol
37{
38
39class ApplicationData
40{
41    friend class Application;
42
43    ApplicationData(char const *name, ivec2 resolution, float framerate)
44        : app(name, resolution, framerate)
45    { }
46
47#if defined __CELLOS_LV2__
48    Ps3App app;
49#elif defined _XBOX
50    XboxApp app;
51#elif defined __native_client__
52    NaClApp app;
53#elif defined __ANDROID__
54    AndroidApp app;
55#elif defined HAVE_GLES_2X
56    /* FIXME: this macro is only deactivated if we include "lolgl.h" */
57    EglApp app;
58#elif defined USE_SDL
59    SdlApp app;
60#else
61#   error No application class available on this platform
62#endif
63};
64
65/*
66 * Public Application class
67 */
68
69Application::Application(char const *name, ivec2 resolution, float framerate)
70{
71    data = new ApplicationData(name, resolution, framerate);
72
73    g_world.ExecLua("lua/init.lua");
74}
75
76bool Application::MustTick()
77{
78    return !Ticker::Finished();
79}
80
81void Application::Tick()
82{
83    data->app.Tick();
84}
85
86void Application::ShowPointer(bool show)
87{
88    data->app.ShowPointer(show);
89}
90
91Application::~Application()
92{
93    delete data;
94}
95
96} /* namespace lol */
97
Note: See TracBrowser for help on using the repository browser.