aboutsummaryrefslogtreecommitdiff
path: root/src/Core/Application.h
blob: 922af67f1534cde573a4df7375229b8350528ef2 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once

#include "Window.h"
#include "Event.h"
#include "Camera.h"
#include <memory>
#include <functional>

namespace Donut
{
    class VertexArray;
    class VertexBuffer;
    class IndexBuffer;
    class Shader;
    class Texture2D;
};

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);
        void UpdateTexture();
    private:
        std::unique_ptr<Window> m_Window;
        bool m_Running;
        bool m_Minimized;

        std::shared_ptr<VertexArray> m_VertexArray;
        std::shared_ptr<VertexBuffer> m_VertexBuffer;
        std::shared_ptr<IndexBuffer> m_IndexBuffer;
        std::shared_ptr<Shader> m_Shader;
        std::shared_ptr<Texture2D> m_Texture;
        
        // Compute shader related members
        std::shared_ptr<Shader> m_ComputeShader;
        std::shared_ptr<Texture2D> m_ProcessedTexture;
        float m_ComputeBrightness;
        float m_ComputeContrast;
        float m_ComputeSaturation;
        bool m_UseComputeShader;
        
        std::unique_ptr<Camera> m_Camera;
        
        bool m_Keys[1024] = { false };
        bool m_FirstMouse = true;
        float m_LastX = 0.0f;
        float m_LastY = 0.0f;
        float m_DeltaTime = 0.0f;
        float m_LastFrame = 0.0f;
        bool m_MouseDragging = false;
        float m_TextureTime = 0.0f;

        static Application* s_Instance;
    };
}