aboutsummaryrefslogtreecommitdiff
path: root/src/Core/Application.h
blob: 92ab781f65ec15ef33e57ac970eeebb5a451bf29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include <memory>
#include <functional>

#include "Window.h"
#include "Event.h"
#include "StateManager.h"
#include "Log.h"

namespace Donut
{
    class Application
    {
    public:
        Application(const std::string& name = "Donut", 
                    int width = 1280, int height = 720);
        ~Application();

        void Run();
        void Close();

        Window& GetWindow()       { return *m_Window;   }
        static Application& Get() { return *s_Instance; }
    private:
        void OnInit();
        void OnShutdown();
        void OnUpdate();
        void OnRender();
        void OnEvent(Event& event);
    private:
        std::unique_ptr<StateManager> m_StateManager;
        std::unique_ptr<Window> m_Window;

        bool m_Running;
        bool m_Minimized;
        
        float m_DeltaTime = 0.0f;
        float m_LastFrame = 0.0f;

        static Application* s_Instance;
    };
}