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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#pragma once
#include "floormat/main.hpp"
#include "floormat/settings.hpp"
#include "src/world.hpp"
#include "draw/ground.hpp"
#include "draw/wall.hpp"
#include "draw/anim.hpp"
#include "shaders/texture-unit-cache.hpp"
#include "shaders/shader.hpp"
#include "shaders/lightmap.hpp"
#include "main/clickable.hpp"
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Magnum/Timeline.h>
#include <Magnum/Math/Range.h>
#include <Magnum/GL/DebugOutput.h>
#include <Magnum/Platform/Sdl2Application.h>
#define FM_USE_DEPTH32
#ifdef FM_USE_DEPTH32
#include <Magnum/GL/Framebuffer.h>
#include <Magnum/GL/Renderbuffer.h>
#include <Magnum/GL/Texture.h>
#endif
namespace floormat {
struct floormat_app;
struct scenery;
class anim_atlas;
struct clickable;
class path_search;
class astar;
struct main_impl final : Platform::Sdl2Application, floormat_main
{
#ifdef FM_USE_DEPTH32
struct Framebuffer final {
GL::Framebuffer fb{NoCreate};
GL::Renderbuffer depth{NoCreate};
GL::Texture2D color{NoCreate};
};
#endif
explicit main_impl(floormat_app& app, fm_settings&& opts, int& argc, char** argv) noexcept;
~main_impl() noexcept override;
int exec() override;
void quit(int status) override;
tile_shader& shader() noexcept override;
const tile_shader& shader() const noexcept override;
struct lightmap_shader& lightmap_shader() noexcept override;
class world& world() noexcept override;
class world& reset_world() noexcept override;
class world& reset_world(class world&& w) noexcept override;
SDL_Window* window() noexcept override;
fm_settings& settings() noexcept override;
const fm_settings& settings() const noexcept override;
global_coords pixel_to_tile(Vector2d position) const noexcept override;
Vector2d pixel_to_tile_(Vector2d position) const noexcept override;
ArrayView<const clickable> clickable_scenery() const noexcept override;
ArrayView<clickable> clickable_scenery() noexcept override;
Platform::Sdl2Application& application() noexcept override;
const Platform::Sdl2Application& application() const noexcept override;
[[maybe_unused]] void viewportEvent(ViewportEvent& event) override;
[[maybe_unused]] void mousePressEvent(MouseEvent& event) override;
[[maybe_unused]] void mouseReleaseEvent(MouseEvent& event) override;
[[maybe_unused]] void mouseMoveEvent(MouseMoveEvent& event) override;
[[maybe_unused]] void mouseScrollEvent(MouseScrollEvent& event) override;
[[maybe_unused]] void textInputEvent(TextInputEvent& event) override;
//[[maybe_unused]] void textEditingEvent(TextEditingEvent& event) override;
[[maybe_unused]] void keyPressEvent(KeyEvent& event) override;
[[maybe_unused]] void keyReleaseEvent(KeyEvent& event) override;
[[maybe_unused]] void anyEvent(SDL_Event& event) override;
void drawEvent() override;
void bind() noexcept override;
void do_update();
void update_window_state();
struct meshes meshes() noexcept override;
bool is_text_input_active() const noexcept override;
void start_text_input() noexcept override;
void stop_text_input() noexcept override;
void debug_callback(unsigned src, unsigned type, unsigned id, unsigned severity, StringView str) const;
void set_cursor(uint32_t cursor) noexcept override;
uint32_t cursor() const noexcept override;
struct texture_unit_cache& texture_unit_cache() override;
path_search& search() override;
class astar& astar() override;
private:
struct texture_unit_cache _tuc;
fm_settings s;
[[maybe_unused]] char _dummy = (register_debug_callback(), '\0');
floormat_app& app; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
tile_shader _shader;
struct lightmap_shader _lightmap_shader{_tuc};
Array<clickable> _clickable_scenery;
class world _world{};
Magnum::Timeline timeline;
uint32_t _mouse_cursor = (uint32_t)-1;
ground_mesh _ground_mesh;
wall_mesh _wall_mesh;
anim_mesh _anim_mesh;
#ifdef FM_USE_DEPTH32
Framebuffer framebuffer;
#endif
safe_ptr<path_search> _search;
safe_ptr<class astar> _astar;
struct {
float value = 0;
float jitter = 0;
bool do_sleep = false;
bool has_focus = true;
} dt_expected;
Timeline fps_sample_timeline;
void recalc_viewport(Vector2i fb_size, Vector2i win_size) noexcept;
void draw_world() noexcept;
//bool draw_lights(chunk& c, const std::array<chunk*, 8>& neighbors) noexcept;
//bool draw_lights_for_chunk(chunk& c, Vector2b neighbor_offset) noexcept;
draw_bounds get_draw_bounds() const noexcept override;
void register_debug_callback();
static Configuration make_conf(const fm_settings& s);
static GLConfiguration make_gl_conf(const fm_settings& s);
static Configuration::WindowFlags make_window_flags(const fm_settings& s);
};
} // namespace floormat
|