@@ -15,6 +15,7 @@ liblol_a_SOURCES = \ | |||||
\ | \ | ||||
lol/unit.h \ | lol/unit.h \ | ||||
\ | \ | ||||
application/application.cpp application/application.h \ | |||||
eglapp.cpp eglapp.h \ | eglapp.cpp eglapp.h \ | ||||
\ | \ | ||||
$(ps3_sources) \ | $(ps3_sources) \ | ||||
@@ -0,0 +1,72 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include "core.h" | |||||
#include "lolgl.h" | |||||
#if defined __CELLOS_LV2__ | |||||
# include "platform/ps3/ps3app.h" | |||||
#elif defined HAVE_GLES_2X | |||||
# include "eglapp.h" | |||||
#else | |||||
# include "platform/sdl/sdlapp.h" | |||||
# include "platform/sdl/sdlinput.h" | |||||
#endif | |||||
using namespace std; | |||||
namespace lol | |||||
{ | |||||
class ApplicationData | |||||
{ | |||||
friend class Application; | |||||
ApplicationData(char const *name, ivec2 resolution, float framerate) | |||||
: app(name, resolution, framerate) | |||||
{ } | |||||
#if defined __CELLOS_LV2__ | |||||
Ps3App app; | |||||
#elif defined HAVE_GLES_2X | |||||
/* FIXME: this macro is only deactivated if we include "lolgl.h" */ | |||||
EglApp app; | |||||
#elif defined HAVE_SDL_H | |||||
SdlApp app; | |||||
#else | |||||
# error No application class available on this platform | |||||
#endif | |||||
}; | |||||
/* | |||||
* Public Application class | |||||
*/ | |||||
Application::Application(char const *name, ivec2 resolution, float framerate) | |||||
{ | |||||
data = new ApplicationData(name, resolution, framerate); | |||||
} | |||||
void Application::Run() | |||||
{ | |||||
data->app.Run(); | |||||
} | |||||
Application::~Application() | |||||
{ | |||||
delete data; | |||||
} | |||||
} /* namespace lol */ | |||||
@@ -0,0 +1,39 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
// | |||||
// The Application class | |||||
// --------------------- | |||||
// | |||||
#if !defined __LOL_APPLICATION_H__ | |||||
#define __LOL_APPLICATION_H__ | |||||
namespace lol | |||||
{ | |||||
class ApplicationData; | |||||
class Application | |||||
{ | |||||
public: | |||||
Application(char const *name, ivec2 resolution, float framerate); | |||||
~Application(); | |||||
void Run(); | |||||
private: | |||||
ApplicationData *data; | |||||
}; | |||||
} /* namespace lol */ | |||||
#endif // __LOL_APPLICATION_H__ | |||||
@@ -98,6 +98,7 @@ static inline int isnan(float f) | |||||
#include "layer.h" | #include "layer.h" | ||||
#include "shader/shader.h" | #include "shader/shader.h" | ||||
#include "image/image.h" | #include "image/image.h" | ||||
#include "application/application.h" | |||||
// Managers | // Managers | ||||
#include "ticker.h" | #include "ticker.h" | ||||
@@ -102,6 +102,9 @@ Ps3App::Ps3App(char const *title, ivec2 res, float fps) : | |||||
Ticker::Setup(fps); | Ticker::Setup(fps); | ||||
Video::Setup(res); | Video::Setup(res); | ||||
Audio::Setup(2); | Audio::Setup(2); | ||||
/* Autoreleased objects */ | |||||
new Ps3Input(); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -19,6 +19,7 @@ | |||||
#include "core.h" | #include "core.h" | ||||
#include "lolgl.h" | #include "lolgl.h" | ||||
#include "platform/sdl/sdlapp.h" | #include "platform/sdl/sdlapp.h" | ||||
#include "platform/sdl/sdlinput.h" | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
@@ -67,6 +68,9 @@ SdlApp::SdlApp(char const *title, ivec2 res, float fps) : | |||||
Ticker::Setup(fps); | Ticker::Setup(fps); | ||||
Video::Setup(ivec2(video->w, video->h)); | Video::Setup(ivec2(video->w, video->h)); | ||||
Audio::Setup(2); | Audio::Setup(2); | ||||
/* Autoreleased objects */ | |||||
new SdlInput(); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -19,15 +19,6 @@ | |||||
using namespace std; | using namespace std; | ||||
using namespace lol; | using namespace lol; | ||||
#if defined __CELLOS_LV2__ | |||||
# include "platform/ps3/ps3app.h" | |||||
#elif defined HAVE_GLES_2X | |||||
# include "eglapp.h" | |||||
#else | |||||
# include "platform/sdl/sdlapp.h" | |||||
# include "platform/sdl/sdlinput.h" | |||||
#endif | |||||
#if USE_SDL && defined __APPLE__ | #if USE_SDL && defined __APPLE__ | ||||
# include <SDL_main.h> | # include <SDL_main.h> | ||||
#endif | #endif | ||||
@@ -38,18 +29,9 @@ using namespace lol; | |||||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||||
{ | { | ||||
#if defined __CELLOS_LV2__ | |||||
Ps3App app("Quad", ivec2(640, 480), 60.0f); | |||||
#elif defined HAVE_GLES_2X | |||||
EglApp app("Quad", ivec2(640, 480), 60.0f); | |||||
#else | |||||
SdlApp app("Quad", ivec2(640, 480), 60.0f); | |||||
#endif | |||||
Application app("Quad", ivec2(640, 480), 60.0f); | |||||
/* Register an input driver and some debug stuff */ | |||||
#if !defined HAVE_GLES_2X | |||||
new SdlInput(); | |||||
#endif | |||||
/* Register some debug stuff */ | |||||
new DebugFps(5, 5); | new DebugFps(5, 5); | ||||
new DebugQuad(); | new DebugQuad(); | ||||