diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-07-07 00:25:19 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-07-07 00:25:19 +0100 |
commit | b43ed0554f5d6326f80e8d6bd85d75a422ca8c05 (patch) | |
tree | 596e967d69b073109dad7db437a60093bf499e26 /application/main.cpp | |
parent | Replace deprecated GL_QUADS usage in text rendering (diff) | |
parent | Replace deprecated GL_QUADS usage in text rendering (diff) | |
download | ilt-b43ed0554f5d6326f80e8d6bd85d75a422ca8c05.tar.bz2 ilt-b43ed0554f5d6326f80e8d6bd85d75a422ca8c05.tar.xz ilt-b43ed0554f5d6326f80e8d6bd85d75a422ca8c05.zip |
Merge branch 'imgui'
Diffstat (limited to 'application/main.cpp')
-rw-r--r-- | application/main.cpp | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/application/main.cpp b/application/main.cpp index f0ba8bb..d58cf6d 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -1,6 +1,7 @@ +#include "ui/mainApplication.h" +#include "ui/mainWindow.h" #include <array> #include <assetFactory/assetFactory.h> -#include <chrono> #include <collection.h> #include <game/activities/go.h> #include <game/activities/idle.h> @@ -31,17 +32,14 @@ static const int DISPLAY_WIDTH = 1280; static const int DISPLAY_HEIGHT = 1024; -class MainApplication : public GameState, public ApplicationBase { +class DummyMainApplication : public GameState, public MainApplication { public: - using Windows = Collection<Window>; - int run() { geoData = std::make_shared<GeoData>(GeoData::loadFromAsciiGrid("test/fixtures/height/SD19.asc")); - Windows windows; - windows.create<GameMainWindow>(DISPLAY_WIDTH, DISPLAY_HEIGHT); + windows.create<MainWindow>(DISPLAY_WIDTH, DISPLAY_HEIGHT)->setContent<GameMainWindow>(); world.create<Terrain>(geoData); world.create<Water>(geoData); @@ -89,41 +87,15 @@ public: } } - auto t_start = std::chrono::high_resolution_clock::now(); - while (isRunning) { - processInputs(windows); - const auto t_end = std::chrono::high_resolution_clock::now(); - const auto t_passed = std::chrono::duration_cast<TickDuration>(t_end - t_start); - - world.apply(&WorldObject::tick, t_passed); - windows.apply(&Window::tick, t_passed); - windows.apply(&Window::refresh); - - t_start = t_end; - } + mainLoop(); world.objects.clear(); return 0; } - -private: - void - processInputs(const Windows & windows) - { - for (SDL_Event e; SDL_PollEvent(&e);) { - if (e.type == SDL_QUIT) { - isRunning = false; - return; - } - windows.applyOne(&Window::handleInput, e); - } - } - - bool isRunning {true}; }; int main(int, char **) { - return std::make_shared<MainApplication>()->run(); + return std::make_shared<DummyMainApplication>()->run(); } |