hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/states/simulation_state.h
blob: a0d9e73db9d388823730f3580db9bef780080af9 (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
#pragma once

#include "core/state.h"
#include "core/event.h"
#include "core/camera.h"
#include "core/log.h"

#include "rendering/vertex_array.h"
#include "rendering/vertex_buffer.h"
#include "rendering/index_buffer.h"
#include "rendering/shader.h"
#include "rendering/texture.h"

namespace Donut
{
    class SimulationState
        : public State
    {
    public:
        ~SimulationState() = default;
        
        void on_enter()                 override;
        void on_exit()                  override;
        void on_update(float delta_time) override;
        void on_render()                override;
        void on_event(Event& event)     override;
    private:
        void handle_key_input(float delta_time);
        void update_texture();
    private:
        std::unique_ptr<Camera> m_camera;
        
        std::shared_ptr<VertexArray>  m_vertex_array;
        std::shared_ptr<VertexBuffer> m_vertex_buffer;
        std::shared_ptr<IndexBuffer>  m_index_buffer;
        std::shared_ptr<Shader>       m_shader;
        std::shared_ptr<Texture2D>    m_texture;
        
        std::shared_ptr<Shader>    m_compute_shader;
        std::shared_ptr<Texture2D> m_processed_texture;
        
        float m_compute_brightness = 0.0f;
        float m_compute_contrast   = 1.0f;
        float m_compute_saturation = 1.0f;
        bool  m_use_compute_shader  = true;
        
        bool  m_keys[1024]    = { false };
        bool  m_first_mouse    = true;
        float m_last_x         = 0.0f;
        float m_last_y         = 0.0f;
        float m_delta_time     = 0.0f;
        float m_last_frame     = 0.0f;
        bool  m_mouse_dragging = false;
        float m_texture_time   = 0.0f;
    };
};