]> git.localhorst.tv Git - blank.git/commitdiff
move init out of Application class
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 4 Aug 2015 16:12:04 +0000 (18:12 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 4 Aug 2015 16:12:04 +0000 (18:12 +0200)
src/app/Application.hpp
src/app/Runtime.cpp
src/app/app.cpp

index 636b82e85899c389a7f69437a001495b638ec428..5909e3ba1437500497b69cee79925b4c5e267059 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "Assets.hpp"
 #include "FrameCounter.hpp"
-#include "init.hpp"
 #include "RandomWalk.hpp"
 #include "../audio/Audio.hpp"
 #include "../graphics/Viewport.hpp"
@@ -15,6 +14,8 @@
 
 namespace blank {
 
+class Window;
+
 class Application {
 
 public:
@@ -27,7 +28,7 @@ public:
                World::Config world = World::Config();
        };
 
-       explicit Application(const Config &);
+       Application(Window &, const Config &);
        ~Application();
 
        Application(const Application &) = delete;
@@ -56,7 +57,7 @@ public:
        static Entity &MakeTestEntity(World &);
 
 private:
-       Init init;
+       Window &window;
        Viewport viewport;
        Assets assets;
        Audio audio;
index e5f74b459ec14d38a7b589b81623d470056d1c8f..6a4c783ef50222b0664fe61489e3b7443674ff70 100644 (file)
@@ -1,5 +1,7 @@
 #include "Runtime.hpp"
 
+#include "init.hpp"
+
 #include <cctype>
 #include <cstdlib>
 #include <iostream>
@@ -141,7 +143,8 @@ int Runtime::Execute() {
                return 1;
        }
 
-       Application app(config);
+       Init init(config.doublebuf, config.multisampling);
+       Application app(init.window, config);
        switch (mode) {
                default:
                case NORMAL:
index 59070a56311d01c7e129a852b717e9313431aae2..3111091377afe0fd0ccd25fa75b6a18bd5952e45 100644 (file)
@@ -2,6 +2,7 @@
 #include "Assets.hpp"
 #include "FrameCounter.hpp"
 
+#include "init.hpp"
 #include "../audio/Sound.hpp"
 #include "../graphics/Font.hpp"
 #include "../world/BlockType.hpp"
@@ -27,8 +28,8 @@ string get_asset_path() {
 
 namespace blank {
 
-Application::Application(const Config &config)
-: init(config.doublebuf, config.multisampling)
+Application::Application(Window &win, const Config &config)
+: window(win)
 , viewport()
 , assets(get_asset_path())
 , audio()
@@ -87,7 +88,7 @@ void Application::RunS(size_t n, size_t t) {
 void Application::Run() {
        running = true;
        Uint32 last = SDL_GetTicks();
-       init.window.GrabMouse();
+       window.GrabMouse();
        while (running) {
                Uint32 now = SDL_GetTicks();
                int delta = now - last;
@@ -144,10 +145,10 @@ void Application::HandleEvents() {
 void Application::Handle(const SDL_WindowEvent &event) {
        switch (event.event) {
                case SDL_WINDOWEVENT_FOCUS_GAINED:
-                       init.window.GrabMouse();
+                       window.GrabMouse();
                        break;
                case SDL_WINDOWEVENT_FOCUS_LOST:
-                       init.window.ReleaseMouse();
+                       window.ReleaseMouse();
                        break;
                case SDL_WINDOWEVENT_RESIZED:
                        viewport.Resize(event.data1, event.data2);
@@ -183,7 +184,7 @@ void Application::Render() {
        interface.Render(viewport);
 
        counter.ExitRender();
-       init.window.Flip();
+       window.Flip();
 }