hachem.wtf
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-20 01:57:44 +0200
committerhachem <im@hachem.wtf>2026-08-20 02:10:49 +0200
commit7d39ee93a6d354e727c7534a18663f1d00d46b0f (patch)
treea188023b61d14dcb859e08e6f8f8dd30df11780f
parentdce67620b95a9555c7db950196b22f1bb88a307b (diff)
refactor: trailing return types in core
-rw-r--r--src/core/application.cpp34
-rw-r--r--src/core/application.h32
-rw-r--r--src/core/camera.cpp44
-rw-r--r--src/core/camera.h159
-rw-r--r--src/core/event.h134
-rw-r--r--src/core/hdri_manager.cpp14
-rw-r--r--src/core/hdri_manager.h23
-rw-r--r--src/core/log.cpp64
-rw-r--r--src/core/log.h63
-rw-r--r--src/core/memory.h14
-rw-r--r--src/core/settings_manager.cpp16
-rw-r--r--src/core/settings_manager.h86
-rw-r--r--src/core/state.h14
-rw-r--r--src/core/state_manager.cpp22
-rw-r--r--src/core/state_manager.h37
-rw-r--r--src/core/theme_manager.cpp8
-rw-r--r--src/core/theme_manager.h14
-rw-r--r--src/core/window.cpp80
-rw-r--r--src/core/window.h64
19 files changed, 466 insertions, 456 deletions
diff --git a/src/core/application.cpp b/src/core/application.cpp
index 0f07979..11c7bd0 100644
--- a/src/core/application.cpp
+++ b/src/core/application.cpp
@@ -53,7 +53,7 @@ namespace Donut
s_instance = nullptr;
}
- void Application::run()
+ auto Application::run() -> void
{
while (m_running)
{
@@ -76,7 +76,7 @@ namespace Donut
}
}
- void Application::build_vulkan_ui()
+ auto Application::build_vulkan_ui() -> void
{
ImGui::Begin("Donut - Vulkan backend");
ImGui::Text("Geodesic black hole through Vulkan (MoltenVK).");
@@ -87,22 +87,22 @@ namespace Donut
ImGui::End();
}
- void Application::close()
+ auto Application::close() -> void
{
m_running = false;
}
- void Application::on_event(Event& event)
+ auto Application::on_event(Event& event) -> void
{
EventDispatcher dispatcher(event);
- dispatcher.dispatch<WindowCloseEvent>([this, &event](WindowCloseEvent& e)
+ dispatcher.dispatch<WindowCloseEvent>([this, &event](WindowCloseEvent& e)
{
m_running = false;
event.handled = true;
return true;
});
-
- dispatcher.dispatch<WindowResizeEvent>([this, &event](WindowResizeEvent& e)
+
+ dispatcher.dispatch<WindowResizeEvent>([this, &event](WindowResizeEvent& e)
{
if (e.get_width() == 0 || e.get_height() == 0)
m_minimized = true;
@@ -121,7 +121,7 @@ namespace Donut
event.handled = true;
return true;
});
-
+
dispatcher.dispatch<KeyPressedEvent>([this, &event](KeyPressedEvent& e)
{
if (!m_state_manager)
@@ -144,7 +144,7 @@ namespace Donut
event.handled = true;
return true;
}
-
+
return true;
});
@@ -152,7 +152,7 @@ namespace Donut
m_state_manager->on_event(event);
}
- void Application::on_init()
+ auto Application::on_init() -> void
{
if (RendererAPI::get_api() == RendererAPI::API::Vulkan)
{
@@ -182,7 +182,7 @@ namespace Donut
m_state_manager->switch_to_state("Config");
}
- void Application::on_shutdown()
+ auto Application::on_shutdown() -> void
{
if (m_vulkan_renderer)
{
@@ -199,7 +199,7 @@ namespace Donut
Logger::shutdown();
}
- void Application::on_update()
+ auto Application::on_update() -> void
{
float current_frame = (float)glfwGetTime();
m_delta_time = current_frame - m_last_frame;
@@ -208,20 +208,20 @@ namespace Donut
m_state_manager->update(m_delta_time);
}
- void Application::on_render()
+ auto Application::on_render() -> void
{
m_state_manager->render();
m_window->begin_im_gui_frame();
-
+
ImGuizmo::BeginFrame();
ImGuizmo::SetOrthographic(false);
-
+
setup_docking_layout();
m_state_manager->on_im_ui_render();
m_window->end_im_gui_frame();
}
-
- void Application::setup_docking_layout()
+
+ auto Application::setup_docking_layout() -> void
{
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::DockSpaceOverViewport(0, viewport, ImGuiDockNodeFlags_PassthruCentralNode);
diff --git a/src/core/application.h b/src/core/application.h
index 3c76dcc..df6669b 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -15,25 +15,27 @@ namespace Donut
class Application
{
public:
- Application(const std::string& name = "Donut",
+ Application(const std::string& name = "Donut",
int width = 1280, int height = 720);
~Application();
- void run();
- void close();
+ auto run() -> void;
+ auto close() -> void;
+
+ auto get_window() -> Window& { return *m_window; }
+ auto get_state_manager() -> StateManager& { return *m_state_manager; }
+ auto get_engine() -> Engine& { return *m_engine; }
+ static auto get() -> Application& { return *s_instance; }
- Window& get_window() { return *m_window; }
- StateManager& get_state_manager() { return *m_state_manager; }
- Engine& get_engine() { return *m_engine; }
- static Application& get() { return *s_instance; }
private:
- void on_init();
- void on_shutdown();
- void on_update();
- void on_render();
- void on_event(Event& event);
- void setup_docking_layout();
- void build_vulkan_ui();
+ auto on_init() -> void;
+ auto on_shutdown() -> void;
+ auto on_update() -> void;
+ auto on_render() -> void;
+ auto on_event(Event& event) -> void;
+ auto setup_docking_layout() -> void;
+ auto build_vulkan_ui() -> void;
+
private:
Scope<StateManager> m_state_manager;
Scope<Window> m_window;
@@ -42,7 +44,7 @@ namespace Donut
bool m_running;
bool m_minimized;
-
+
float m_delta_time = 0.0f;
float m_last_frame = 0.0f;
diff --git a/src/core/camera.cpp b/src/core/camera.cpp
index 9c2b061..35b7a2f 100644
--- a/src/core/camera.cpp
+++ b/src/core/camera.cpp
@@ -12,7 +12,7 @@ namespace Donut
recalculate_view_matrix();
}
- void Camera::set_projection(float fov, float aspect_ratio, float near_plane, float far_plane)
+ auto Camera::set_projection(float fov, float aspect_ratio, float near_plane, float far_plane) -> void
{
m_fov = fov;
m_aspect_ratio = aspect_ratio;
@@ -21,13 +21,13 @@ namespace Donut
recalculate_projection_matrix();
}
- void Camera::recalculate_projection_matrix()
+ auto Camera::recalculate_projection_matrix() -> void
{
m_projection_matrix = glm::perspective(glm::radians(m_fov), m_aspect_ratio, m_near_plane, m_far_plane);
m_view_projection_matrix = m_projection_matrix * m_view_matrix;
}
- void Camera::recalculate_view_matrix()
+ auto Camera::recalculate_view_matrix() -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -45,7 +45,7 @@ namespace Donut
glm::vec3 right = glm::normalize(glm::cross(front, world_up));
glm::vec3 up = glm::normalize(glm::cross(right, front));
- m_view_matrix = glm::lookAt(m_position, m_position + front, up);
+ m_view_matrix = glm::lookAt(m_position, m_position + front, up);
m_view_projection_matrix = m_projection_matrix * m_view_matrix;
}
else if (m_camera_mode == CameraMode::Orbital)
@@ -53,13 +53,13 @@ namespace Donut
glm::vec3 position = get_orbital_position();
glm::vec3 target = m_orbital_target;
glm::vec3 up(0.0f, 1.0f, 0.0f);
-
+
m_view_matrix = glm::lookAt(position, target, up);
m_view_projection_matrix = m_projection_matrix * m_view_matrix;
}
}
- glm::vec3 Camera::get_forward_direction() const
+ auto Camera::get_forward_direction() const -> glm::vec3
{
float pitch = glm::radians(m_rotation.x);
float yaw = glm::radians(m_rotation.y);
@@ -72,18 +72,18 @@ namespace Donut
return glm::normalize(direction);
}
- glm::vec3 Camera::get_right_direction() const
+ auto Camera::get_right_direction() const -> glm::vec3
{
glm::vec3 world_up(0.0f, 1.0f, 0.0f);
return glm::normalize(glm::cross(get_forward_direction(), world_up));
}
- glm::vec3 Camera::get_up_direction() const
+ auto Camera::get_up_direction() const -> glm::vec3
{
return glm::normalize(glm::cross(get_right_direction(), get_forward_direction()));
}
- void Camera::on_mouse_move(float x_offset, float y_offset, bool constrain_pitch)
+ auto Camera::on_mouse_move(float x_offset, float y_offset, bool constrain_pitch) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -105,7 +105,7 @@ namespace Donut
}
}
- void Camera::move_forward(float delta_time)
+ auto Camera::move_forward(float delta_time) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -114,7 +114,7 @@ namespace Donut
}
}
- void Camera::move_backward(float delta_time)
+ auto Camera::move_backward(float delta_time) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -123,7 +123,7 @@ namespace Donut
}
}
- void Camera::move_right(float delta_time)
+ auto Camera::move_right(float delta_time) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -132,7 +132,7 @@ namespace Donut
}
}
- void Camera::move_left(float delta_time)
+ auto Camera::move_left(float delta_time) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -141,7 +141,7 @@ namespace Donut
}
}
- void Camera::move_up(float delta_time)
+ auto Camera::move_up(float delta_time) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -151,7 +151,7 @@ namespace Donut
}
}
- void Camera::move_down(float delta_time)
+ auto Camera::move_down(float delta_time) -> void
{
if (m_camera_mode == CameraMode::FPS)
{
@@ -161,7 +161,7 @@ namespace Donut
}
}
- glm::vec3 Camera::get_orbital_position() const
+ auto Camera::get_orbital_position() const -> glm::vec3
{
float clamped_elevation = glm::clamp(m_elevation, 0.01f, float(std::numbers::pi) - 0.01f);
return glm::vec3
@@ -172,7 +172,7 @@ namespace Donut
);
}
- void Camera::update_orbital()
+ auto Camera::update_orbital() -> void
{
m_orbital_target = glm::vec3(0.0f, 0.0f, 0.0f);
if (m_dragging || m_panning)
@@ -182,24 +182,24 @@ namespace Donut
recalculate_view_matrix();
}
- void Camera::process_orbital_mouse_move(double x, double y)
+ auto Camera::process_orbital_mouse_move(double x, double y) -> void
{
if (m_dragging && !m_panning)
{
float dx = float(x - m_last_x_orbital);
float dy = float(y - m_last_y_orbital);
-
+
m_azimuth += dx * m_orbital_speed;
m_elevation -= dy * m_orbital_speed;
m_elevation = glm::clamp(m_elevation, 0.01f, float(std::numbers::pi) - 0.01f);
}
-
+
m_last_x_orbital = x;
m_last_y_orbital = y;
update_orbital();
}
- void Camera::process_orbital_mouse_button(int button, int action, int mods)
+ auto Camera::process_orbital_mouse_button(int button, int action, int mods) -> void
{
if (button == GLFW_MOUSE_BUTTON_LEFT)
{
@@ -216,7 +216,7 @@ namespace Donut
}
}
- void Camera::process_orbital_scroll(double x_offset, double y_offset)
+ auto Camera::process_orbital_scroll(double x_offset, double y_offset) -> void
{
m_orbital_radius -= y_offset * m_zoom_speed;
m_orbital_radius = glm::clamp(m_orbital_radius, m_orbital_min_radius, m_orbital_max_radius);
diff --git a/src/core/camera.h b/src/core/camera.h
index 677cb71..c997c35 100644
--- a/src/core/camera.h
+++ b/src/core/camera.h
@@ -16,85 +16,86 @@ namespace Donut
class Camera
{
public:
- Camera(float fov = 45.0f, float aspect_ratio = 16.0f / 9.0f,
+ Camera(float fov = 45.0f, float aspect_ratio = 16.0f / 9.0f,
float near_plane = 0.1f, float far_plane = 100.0f);
~Camera() = default;
- void set_position(const glm::vec3& position) { m_position = position; recalculate_view_matrix(); }
- void set_rotation(const glm::vec3& rotation) { m_rotation = rotation; recalculate_view_matrix(); }
-
- const glm::vec3& get_position() const { return m_position; }
- const glm::vec3& get_rotation() const { return m_rotation; }
-
- glm::vec3 get_forward_direction() const;
- glm::vec3 get_right_direction() const;
- glm::vec3 get_up_direction() const;
+ auto set_position(const glm::vec3& position) -> void { m_position = position; recalculate_view_matrix(); }
+ auto set_rotation(const glm::vec3& rotation) -> void { m_rotation = rotation; recalculate_view_matrix(); }
- const glm::mat4& get_projection_matrix() const { return m_projection_matrix; }
- const glm::mat4& get_view_matrix() const { return m_view_matrix; }
- const glm::mat4& get_view_projection_matrix() const { return m_view_projection_matrix; }
+ auto get_position() const -> const glm::vec3& { return m_position; }
+ auto get_rotation() const -> const glm::vec3& { return m_rotation; }
- void set_projection(float fov, float aspect_ratio, float near_plane, float far_plane);
- void on_mouse_move(float x_offset, float y_offset, bool constrain_pitch = true);
-
- void move_forward(float delta_time);
- void move_backward(float delta_time);
- void move_right(float delta_time);
- void move_left(float delta_time);
- void move_up(float delta_time);
- void move_down(float delta_time);
+ auto get_forward_direction() const -> glm::vec3;
+ auto get_right_direction() const -> glm::vec3;
+ auto get_up_direction() const -> glm::vec3;
- void set_mouse_sensitivity(float sensitivity) { m_mouse_sensitivity = sensitivity; }
- float get_mouse_sensitivity() const { return m_mouse_sensitivity; }
+ auto get_projection_matrix() const -> const glm::mat4& { return m_projection_matrix; }
+ auto get_view_matrix() const -> const glm::mat4& { return m_view_matrix; }
+ auto get_view_projection_matrix() const -> const glm::mat4& { return m_view_projection_matrix; }
- void set_movement_speed(float speed) { m_movement_speed = speed; }
- float get_movement_speed() const { return m_movement_speed; }
+ auto set_projection(float fov, float aspect_ratio, float near_plane, float far_plane) -> void;
+ auto on_mouse_move(float x_offset, float y_offset, bool constrain_pitch = true) -> void;
- void set_orbital_target(const glm::vec3& target) { m_orbital_target = target; }
- const glm::vec3& get_orbital_target() const { return m_orbital_target; }
-
- void set_orbital_radius(double radius) { m_orbital_radius = radius; }
- double get_orbital_radius() const { return m_orbital_radius; }
-
- void set_orbital_limits(double min_radius, double max_radius)
- {
- m_orbital_min_radius = min_radius;
- m_orbital_max_radius = max_radius;
+ auto move_forward(float delta_time) -> void;
+ auto move_backward(float delta_time) -> void;
+ auto move_right(float delta_time) -> void;
+ auto move_left(float delta_time) -> void;
+ auto move_up(float delta_time) -> void;
+ auto move_down(float delta_time) -> void;
+
+ auto set_mouse_sensitivity(float sensitivity) -> void { m_mouse_sensitivity = sensitivity; }
+ auto get_mouse_sensitivity() const -> float { return m_mouse_sensitivity; }
+
+ auto set_movement_speed(float speed) -> void { m_movement_speed = speed; }
+ auto get_movement_speed() const -> float { return m_movement_speed; }
+
+ auto set_orbital_target(const glm::vec3& target) -> void { m_orbital_target = target; }
+ auto get_orbital_target() const -> const glm::vec3& { return m_orbital_target; }
+
+ auto set_orbital_radius(double radius) -> void { m_orbital_radius = radius; }
+ auto get_orbital_radius() const -> double { return m_orbital_radius; }
+
+ auto set_orbital_limits(double min_radius, double max_radius) -> void
+ {
+ m_orbital_min_radius = min_radius;
+ m_orbital_max_radius = max_radius;
}
-
- void set_orbital_speed(float speed) { m_orbital_speed = speed; }
- float get_orbital_speed() const { return m_orbital_speed; }
-
- void set_zoom_speed(double speed) { m_zoom_speed = speed; }
- double get_zoom_speed() const { return m_zoom_speed; }
-
- void set_azimuth(float azimuth) { m_azimuth = azimuth; }
- float get_azimuth() const { return m_azimuth; }
-
- void set_elevation(float elevation) { m_elevation = elevation; }
- float get_elevation() const { return m_elevation; }
-
- glm::vec3 get_orbital_position() const;
- void update_orbital();
- void process_orbital_mouse_move(double x, double y);
- void process_orbital_mouse_button(int button, int action, int mods);
- void process_orbital_scroll(double x_offset, double y_offset);
-
- void set_camera_mode(CameraMode mode) { m_camera_mode = mode; }
- CameraMode get_camera_mode() const { return m_camera_mode; }
-
- bool is_dragging() const { return m_dragging; }
- bool is_panning() const { return m_panning; }
- bool is_moving() const { return m_moving; }
- double get_last_x() const { return m_last_x; }
- double get_last_y() const { return m_last_y; }
+
+ auto set_orbital_speed(float speed) -> void { m_orbital_speed = speed; }
+ auto get_orbital_speed() const -> float { return m_orbital_speed; }
+
+ auto set_zoom_speed(double speed) -> void { m_zoom_speed = speed; }
+ auto get_zoom_speed() const -> double { return m_zoom_speed; }
+
+ auto set_azimuth(float azimuth) -> void { m_azimuth = azimuth; }
+ auto get_azimuth() const -> float { return m_azimuth; }
+
+ auto set_elevation(float elevation) -> void { m_elevation = elevation; }
+ auto get_elevation() const -> float { return m_elevation; }
+
+ auto get_orbital_position() const -> glm::vec3;
+ auto update_orbital() -> void;
+ auto process_orbital_mouse_move(double x, double y) -> void;
+ auto process_orbital_mouse_button(int button, int action, int mods) -> void;
+ auto process_orbital_scroll(double x_offset, double y_offset) -> void;
+
+ auto set_camera_mode(CameraMode mode) -> void { m_camera_mode = mode; }
+ auto get_camera_mode() const -> CameraMode { return m_camera_mode; }
+
+ auto is_dragging() const -> bool { return m_dragging; }
+ auto is_panning() const -> bool { return m_panning; }
+ auto is_moving() const -> bool { return m_moving; }
+ auto get_last_x() const -> double { return m_last_x; }
+ auto get_last_y() const -> double { return m_last_y; }
private:
- void recalculate_view_matrix();
- void recalculate_projection_matrix();
+ auto recalculate_view_matrix() -> void;
+ auto recalculate_projection_matrix() -> void;
+
private:
CameraMode m_camera_mode = CameraMode::FPS;
-
+
glm::mat4 m_projection_matrix;
glm::mat4 m_view_matrix;
glm::mat4 m_view_projection_matrix;
@@ -102,7 +103,7 @@ namespace Donut
glm::vec3 m_position = { 0.0f, 0.0f, 3.0f };
glm::vec3 m_rotation = { 0.0f, 0.0f, 0.0f };
- float m_fov = 45.0f;
+ float m_fov = 45.0f;
float m_aspect_ratio = 16.0f / 9.0f;
float m_near_plane = 0.1f;
float m_far_plane = 100.0f;
@@ -112,19 +113,19 @@ namespace Donut
bool m_first_mouse = true;
float m_last_x = 0.0f;
float m_last_y = 0.0f;
-
- glm::vec3 m_orbital_target = glm::vec3(0.0f, 0.0f, 0.0f);
- double m_orbital_radius = 6.34194e10;
+
+ glm::vec3 m_orbital_target = glm::vec3(0.0f, 0.0f, 0.0f);
+ double m_orbital_radius = 6.34194e10;
double m_orbital_min_radius = 1e10;
double m_orbital_max_radius = 1e12;
- float m_azimuth = 0.0f;
- float m_elevation = static_cast<float>(std::numbers::pi) / 2.0f;
- float m_orbital_speed = 0.01f;
- double m_zoom_speed = 25e9f;
- bool m_dragging = false;
- bool m_panning = false;
- bool m_moving = false;
- double m_last_x_orbital = 0.0;
- double m_last_y_orbital = 0.0;
+ float m_azimuth = 0.0f;
+ float m_elevation = static_cast<float>(std::numbers::pi) / 2.0f;
+ float m_orbital_speed = 0.01f;
+ double m_zoom_speed = 25e9f;
+ bool m_dragging = false;
+ bool m_panning = false;
+ bool m_moving = false;
+ double m_last_x_orbital = 0.0;
+ double m_last_y_orbital = 0.0;
};
}
diff --git a/src/core/event.h b/src/core/event.h
index a1e30e9..1891206 100644
--- a/src/core/event.h
+++ b/src/core/event.h
@@ -46,40 +46,40 @@ namespace Donut
public:
virtual ~Event() = default;
- bool handled = false;
+ virtual auto get_event_type() const -> EventType = 0;
+ virtual auto get_name() const -> const char* = 0;
+ virtual auto get_category_flags() const -> int = 0;
+ virtual auto to_string() const -> std::string { return get_name(); }
- virtual EventType get_event_type() const = 0;
- virtual const char* get_name() const = 0;
- virtual int get_category_flags() const = 0;
- virtual std::string to_string() const { return get_name(); }
+ auto is_in_category(EventCategory category) -> bool { return get_category_flags() & category; }
- bool is_in_category(EventCategory category) { return get_category_flags() & category; }
+ bool handled = false;
};
- #define EVENT_CLASS_TYPE(type) \
- static EventType get_static_type() { return EventType::type; } \
- virtual EventType get_event_type() const override { return get_static_type(); } \
- virtual const char* get_name() const override { return #type; }
-
+ #define EVENT_CLASS_TYPE(type) \
+ static auto get_static_type() -> EventType { return EventType::type; } \
+ virtual auto get_event_type() const -> EventType override { return get_static_type(); } \
+ virtual auto get_name() const -> const char* override { return #type; }
+
#define APPLICATION_EVENT_CLASS_TYPE(type) \
EVENT_CLASS_TYPE(type) \
- virtual int get_category_flags() const override { return EventCategoryApplication; }
-
+ virtual auto get_category_flags() const -> int override { return EventCategoryApplication; }
+
#define MOUSE_EVENT_CLASS_TYPE(type) \
EVENT_CLASS_TYPE(type) \
- virtual int get_category_flags() const override { return EventCategoryMouse | \
- EventCategoryInput; }
-
+ virtual auto get_category_flags() const -> int override { return EventCategoryMouse | \
+ EventCategoryInput; }
+
#define MOUSE_BUTTON_EVENT_CLASS_TYPE(type) \
EVENT_CLASS_TYPE(type) \
- virtual int get_category_flags() const override { return EventCategoryMouseButton | \
- EventCategoryMouse | \
- EventCategoryInput; }
-
+ virtual auto get_category_flags() const -> int override { return EventCategoryMouseButton | \
+ EventCategoryMouse | \
+ EventCategoryInput; }
+
#define KEYBOARD_EVENT_CLASS_TYPE(type) \
EVENT_CLASS_TYPE(type) \
- virtual int get_category_flags() const override { return EventCategoryKeyboard | \
- EventCategoryInput; }
+ virtual auto get_category_flags() const -> int override { return EventCategoryKeyboard | \
+ EventCategoryInput; }
class WindowResizeEvent
: public Event
@@ -88,10 +88,10 @@ namespace Donut
WindowResizeEvent(unsigned int width, unsigned int height)
: m_width(width), m_height(height) { }
- unsigned int get_width() const { return m_width; }
- unsigned int get_height() const { return m_height; }
+ auto get_width() const -> unsigned int { return m_width; }
+ auto get_height() const -> unsigned int { return m_height; }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "WindowResizeEvent: " + std::to_string(m_width) + ", " + std::to_string(m_height);
}
@@ -102,7 +102,7 @@ namespace Donut
unsigned int m_width, m_height;
};
- class WindowCloseEvent
+ class WindowCloseEvent
: public Event
{
public:
@@ -110,7 +110,7 @@ namespace Donut
APPLICATION_EVENT_CLASS_TYPE(WindowClose)
};
- class WindowFocusEvent
+ class WindowFocusEvent
: public Event
{
public:
@@ -118,7 +118,7 @@ namespace Donut
APPLICATION_EVENT_CLASS_TYPE(WindowFocus)
};
- class WindowLostFocusEvent
+ class WindowLostFocusEvent
: public Event
{
public:
@@ -126,17 +126,17 @@ namespace Donut
APPLICATION_EVENT_CLASS_TYPE(WindowLostFocus)
};
- class WindowMovedEvent
+ class WindowMovedEvent
: public Event
{
public:
WindowMovedEvent(int x, int y)
: m_x(x), m_y(y) { }
- int get_x() const { return m_x; }
- int get_y() const { return m_y; }
+ auto get_x() const -> int { return m_x; }
+ auto get_y() const -> int { return m_y; }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "WindowMovedEvent: " + std::to_string(m_x) + ", " + std::to_string(m_y);
}
@@ -147,13 +147,13 @@ namespace Donut
int m_x, m_y;
};
- class KeyEvent
+ class KeyEvent
: public Event
{
public:
- int get_key_code() const { return m_key_code; }
- virtual int get_category_flags() const override { return EventCategoryKeyboard |
- EventCategoryInput; }
+ auto get_key_code() const -> int { return m_key_code; }
+ virtual auto get_category_flags() const -> int override { return EventCategoryKeyboard |
+ EventCategoryInput; }
protected:
KeyEvent(int keycode)
@@ -161,18 +161,18 @@ namespace Donut
int m_key_code;
};
- class KeyPressedEvent
+ class KeyPressedEvent
: public KeyEvent
{
public:
KeyPressedEvent(int keycode, bool is_repeat = false)
: KeyEvent(keycode), m_is_repeat(is_repeat) { }
- bool is_repeat() const { return m_is_repeat; }
+ auto is_repeat() const -> bool { return m_is_repeat; }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
- return "KeyPressedEvent: " + std::to_string(m_key_code) +
+ return "KeyPressedEvent: " + std::to_string(m_key_code) +
" (repeat = " + std::to_string(m_is_repeat) + ")";
}
@@ -182,14 +182,14 @@ namespace Donut
bool m_is_repeat;
};
- class KeyReleasedEvent
+ class KeyReleasedEvent
: public KeyEvent
{
public:
KeyReleasedEvent(int keycode)
: KeyEvent(keycode) { }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "KeyReleasedEvent: " + std::to_string(m_key_code);
}
@@ -197,14 +197,14 @@ namespace Donut
KEYBOARD_EVENT_CLASS_TYPE(KeyReleased)
};
- class KeyTypedEvent
+ class KeyTypedEvent
: public KeyEvent
{
public:
KeyTypedEvent(int keycode)
: KeyEvent(keycode) { }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "KeyTypedEvent: " + std::to_string(m_key_code);
}
@@ -212,17 +212,17 @@ namespace Donut
KEYBOARD_EVENT_CLASS_TYPE(KeyTyped)
};
- class MouseMovedEvent
+ class MouseMovedEvent
: public Event
{
public:
MouseMovedEvent(float x, float y)
: m_mouse_x(x), m_mouse_y(y) { }
- float get_x() const { return m_mouse_x; }
- float get_y() const { return m_mouse_y; }
+ auto get_x() const -> float { return m_mouse_x; }
+ auto get_y() const -> float { return m_mouse_y; }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "MouseMovedEvent: " + std::to_string(m_mouse_x) + ", " + std::to_string(m_mouse_y);
}
@@ -233,17 +233,17 @@ namespace Donut
float m_mouse_x, m_mouse_y;
};
- class MouseScrolledEvent
+ class MouseScrolledEvent
: public Event
{
public:
MouseScrolledEvent(float x_offset, float y_offset)
: m_x_offset(x_offset), m_y_offset(y_offset) { }
- float get_x_offset() const { return m_x_offset; }
- float get_y_offset() const { return m_y_offset; }
+ auto get_x_offset() const -> float { return m_x_offset; }
+ auto get_y_offset() const -> float { return m_y_offset; }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "MouseScrolledEvent: " + std::to_string(m_x_offset) +
", " + std::to_string(m_y_offset);
@@ -255,14 +255,14 @@ namespace Donut
float m_x_offset, m_y_offset;
};
- class MouseButtonEvent
+ class MouseButtonEvent
: public Event
{
public:
- int get_mouse_button() const { return m_button; }
- virtual int get_category_flags() const override { return EventCategoryMouseButton |
- EventCategoryMouse |
- EventCategoryInput; }
+ auto get_mouse_button() const -> int { return m_button; }
+ virtual auto get_category_flags() const -> int override { return EventCategoryMouseButton |
+ EventCategoryMouse |
+ EventCategoryInput; }
protected:
MouseButtonEvent(int button)
@@ -270,14 +270,14 @@ namespace Donut
int m_button;
};
- class MouseButtonPressedEvent
+ class MouseButtonPressedEvent
: public MouseButtonEvent
{
public:
MouseButtonPressedEvent(int button)
: MouseButtonEvent(button) { }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "MouseButtonPressedEvent: " + std::to_string(m_button);
}
@@ -285,14 +285,14 @@ namespace Donut
MOUSE_BUTTON_EVENT_CLASS_TYPE(MouseButtonPressed)
};
- class MouseButtonReleasedEvent
+ class MouseButtonReleasedEvent
: public MouseButtonEvent
{
public:
MouseButtonReleasedEvent(int button)
: MouseButtonEvent(button) { }
- std::string to_string() const override
+ auto to_string() const -> std::string override
{
return "MouseButtonReleasedEvent: " + std::to_string(m_button);
}
@@ -303,11 +303,11 @@ namespace Donut
class EventDispatcher
{
public:
- EventDispatcher(Event& event)
+ EventDispatcher(Event& event)
: m_event(event) { }
template<typename T, typename F>
- bool dispatch(const F& func)
+ auto dispatch(const F& func) -> bool
{
if (m_event.get_event_type() == T::get_static_type())
{
@@ -329,21 +329,21 @@ namespace Donut
EventHandler() = default;
~EventHandler() = default;
- void set_event_callback(const EventCallbackFn& callback)
+ auto set_event_callback(const EventCallbackFn& callback) -> void
{
m_event_callback = callback;
}
- void on_event(Event& event)
+ auto on_event(Event& event) -> void
{
if (m_event_callback)
m_event_callback(event);
}
template<typename T>
- void bind_event(const std::function<void(T&)>& callback)
+ auto bind_event(const std::function<void(T&)>& callback) -> void
{
- m_event_callback = [callback](Event& event)
+ m_event_callback = [callback](Event& event)
{
if (event.get_event_type() == T::get_static_type())
callback(static_cast<T&>(event));
diff --git a/src/core/hdri_manager.cpp b/src/core/hdri_manager.cpp
index 1a5521e..605dcf6 100644
--- a/src/core/hdri_manager.cpp
+++ b/src/core/hdri_manager.cpp
@@ -3,7 +3,7 @@
namespace Donut
{
- Ref<CubemapTexture> HDRIManager::load_hdri(const std::string& path)
+ auto HDRIManager::load_hdri(const std::string& path) -> Ref<CubemapTexture>
{
auto it = m_hdri_cache.find(path);
if (it != m_hdri_cache.end())
@@ -14,7 +14,7 @@ namespace Donut
DONUT_INFO("Loading HDRI: {}", path);
auto hdri = CubemapTexture::create_from_hdri(path);
-
+
if (hdri)
{
m_hdri_cache[path] = hdri;
@@ -26,7 +26,7 @@ namespace Donut
return hdri;
}
- void HDRIManager::set_current_hdri(const std::string& path)
+ auto HDRIManager::set_current_hdri(const std::string& path) -> void
{
auto hdri = load_hdri(path);
if (hdri)
@@ -38,12 +38,12 @@ namespace Donut
DONUT_ERROR("Failed to set current HDRI: {}", path);
}
- std::string HDRIManager::get_hdri_name(const std::string& path) const
+ auto HDRIManager::get_hdri_name(const std::string& path) const -> std::string
{
std::filesystem::path file_path(path);
std::string filename = file_path.stem().string();
std::string name = filename;
-
+
for (size_t i = 0; i < name.length(); ++i)
{
if (name[i] == '_')
@@ -51,11 +51,11 @@ namespace Donut
else if (i == 0 || name[i-1] == ' ')
name[i] = std::toupper(name[i]);
}
-
+
return name;
}
- void HDRIManager::clear_cache()
+ auto HDRIManager::clear_cache() -> void
{
m_hdri_cache.clear();
m_current_hdri.reset();
diff --git a/src/core/hdri_manager.h b/src/core/hdri_manager.h
index 3bdf1cb..d98830f 100644
--- a/src/core/hdri_manager.h
+++ b/src/core/hdri_manager.h
@@ -12,19 +12,20 @@ namespace Donut
class HDRIManager
{
public:
- static HDRIManager& get()
+ static auto get() -> HDRIManager&
{
static HDRIManager instance;
return instance;
}
- Ref<CubemapTexture> load_hdri(const std::string& path);
- Ref<CubemapTexture> get_current_hdri() const { return m_current_hdri; }
-
- void set_current_hdri(const std::string& path);
- const std::vector<std::string>& get_available_hdri() const { return m_available_hdri; }
- std::string get_hdri_name(const std::string& path) const;
- void clear_cache();
+ auto load_hdri(const std::string& path) -> Ref<CubemapTexture>;
+ auto get_current_hdri() const -> Ref<CubemapTexture> { return m_current_hdri; }
+
+ auto set_current_hdri(const std::string& path) -> void;
+ auto get_available_hdri() const -> const std::vector<std::string>& { return m_available_hdri; }
+ auto get_hdri_name(const std::string& path) const -> std::string;
+ auto clear_cache() -> void;
+
private:
HDRIManager() = default;
~HDRIManager() = default;
@@ -33,10 +34,10 @@ namespace Donut
HDRIManager& operator=(const HDRIManager&) = delete;
std::unordered_map<std::string, Ref<CubemapTexture>> m_hdri_cache;
-
+
Ref<CubemapTexture> m_current_hdri;
-
- std::vector<std::string> m_available_hdri =
+
+ std::vector<std::string> m_available_hdri =
{
"assets/hdri/hdr_blue_nebulae_1.hdr",
"assets/hdri/hdr_subdued_blue_nebulae.hdr",
diff --git a/src/core/log.cpp b/src/core/log.cpp
index 0411e20..5a0434f 100644
--- a/src/core/log.cpp
+++ b/src/core/log.cpp
@@ -6,68 +6,68 @@
#include <windows.h>
#endif
-namespace Donut
+namespace Donut
{
Ref<Logger> Logger::s_logger;
- void Logger::init()
+ auto Logger::init() -> void
{
s_logger = create_ref<Logger>();
s_logger->set_log_level(LogLevel::Info);
s_logger->enable_console_output(true);
s_logger->enable_file_output(true);
s_logger->set_log_file("logs/donut.log");
-
+
s_logger->log_message(LogLevel::Info, "Logging system initialized");
}
- void Logger::shutdown()
+ auto Logger::shutdown() -> void
{
if (s_logger)
s_logger->log_message(LogLevel::Info, "Shutting down logging system");
s_logger.reset();
}
- Ref<Logger> Logger::get_logger()
+ auto Logger::get_logger() -> Ref<Logger>
{
return s_logger;
}
Logger::Logger()
- : m_log_level(LogLevel::Info),
- m_console_output(true),
+ : m_log_level(LogLevel::Info),
+ m_console_output(true),
m_file_output(false) { }
- Logger::~Logger()
+ Logger::~Logger()
{
if (m_log_file.is_open())
m_log_file.close();
}
- void Logger::set_log_file(const std::string& filename)
+ auto Logger::set_log_file(const std::string& filename) -> void
{
std::filesystem::path log_path(filename);
std::filesystem::create_directories(log_path.parent_path());
-
+
m_log_file.open(filename, std::ios::app);
if (!m_log_file.is_open())
std::cerr << "Failed to open log file: " << filename << std::endl;
}
- std::string Logger::get_time_stamp()
+ auto Logger::get_time_stamp() -> std::string
{
auto now = std::chrono::system_clock::now();
- auto time_t = std::chrono::system_clock::to_time_t(now);
-
+ auto time = std::chrono::system_clock::to_time_t(now);
+
std::stringstream ss;
- ss << std::put_time(std::localtime(&time_t), "%Y-%m-%d %H:%M:%S");
-
+ ss << std::put_time(std::localtime(&time), "%Y-%m-%d %H:%M:%S");
+
return ss.str();
}
- std::string Logger::get_log_level_string(LogLevel level)
+ auto Logger::get_log_level_string(LogLevel level) -> std::string
{
- switch (level)
+ switch (level)
{
case LogLevel::trace: return "TRACE";
case LogLevel::Info: return "INFO";
@@ -78,43 +78,43 @@ namespace Donut
}
}
- void Logger::set_console_color(LogLevel level)
+ auto Logger::set_console_color(LogLevel level) -> void
{
#if defined(DONUT_WINDOWS)
HANDLE h_console = GetStdHandle(STD_OUTPUT_HANDLE);
WORD color;
-
+
switch (level) {
case LogLevel::trace:
color = FOREGROUND_RED |
- FOREGROUND_GREEN |
+ FOREGROUND_GREEN |
FOREGROUND_BLUE;
break;
case LogLevel::Info:
- color = FOREGROUND_GREEN |
+ color = FOREGROUND_GREEN |
FOREGROUND_INTENSITY;
break;
case LogLevel::Warn:
- color = FOREGROUND_RED |
- FOREGROUND_GREEN |
+ color = FOREGROUND_RED |
+ FOREGROUND_GREEN |
FOREGROUND_INTENSITY;
break;
case LogLevel::Err:
- color = FOREGROUND_RED |
+ color = FOREGROUND_RED |
FOREGROUND_INTENSITY;
break;
case LogLevel::Fatal:
- color = FOREGROUND_RED |
- FOREGROUND_BLUE |
+ color = FOREGROUND_RED |
+ FOREGROUND_BLUE |
FOREGROUND_INTENSITY;
break;
default:
- color = FOREGROUND_RED |
- FOREGROUND_GREEN |
+ color = FOREGROUND_RED |
+ FOREGROUND_GREEN |
FOREGROUND_BLUE;
break;
}
-
+
SetConsoleTextAttribute(h_console, color);
#else
const char* color_code;
@@ -142,12 +142,12 @@ namespace Donut
#endif
}
- void Logger::reset_console_color()
+ auto Logger::reset_console_color() -> void
{
#if defined(DONUT_WINDOWS)
HANDLE h_console = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(h_console, FOREGROUND_RED |
- FOREGROUND_GREEN |
+ SetConsoleTextAttribute(h_console, FOREGROUND_RED |
+ FOREGROUND_GREEN |
FOREGROUND_BLUE);
#else
std::cout << "\033[0m";
diff --git a/src/core/log.h b/src/core/log.h
index 1477226..db6b4b4 100644
--- a/src/core/log.h
+++ b/src/core/log.h
@@ -23,67 +23,70 @@ namespace Donut
Fatal = 5
};
- class Logger
+ class Logger
{
public:
- static void init();
- static void shutdown();
+ Logger();
+ ~Logger();
+
+ static auto init() -> void;
+ static auto shutdown() -> void;
- static Ref<Logger> get_logger();
+ static auto get_logger() -> Ref<Logger>;
template<typename... Args>
- static void trace(const std::string_view& format, const Args&... args)
+ static auto trace(const std::string_view& format, const Args&... args) -> void
{
auto logger = get_logger();
if (logger) logger->log_message(LogLevel::trace, format, args...);
}
template<typename... Args>
- static void info(const std::string_view& format, const Args&... args)
+ static auto info(const std::string_view& format, const Args&... args) -> void
{
auto logger = get_logger();
if (logger) logger->log_message(LogLevel::Info, format, args...);
}
template<typename... Args>
- static void warn(const std::string_view& format, const Args&... args)
+ static auto warn(const std::string_view& format, const Args&... args) -> void
{
auto logger = get_logger();
if (logger) logger->log_message(LogLevel::Warn, format, args...);
}
template<typename... Args>
- static void error(const std::string_view& format, const Args&... args)
+ static auto error(const std::string_view& format, const Args&... args) -> void
{
auto logger = get_logger();
if (logger) logger->log_message(LogLevel::Err, format, args...);
}
template<typename... Args>
- static void fatal(const std::string_view& format, const Args&... args)
+ static auto fatal(const std::string_view& format, const Args&... args) -> void
{
auto logger = get_logger();
if (logger) logger->log_message(LogLevel::Fatal, format, args...);
}
template<typename... Args>
- void log_message(LogLevel level, const std::string_view& format, const Args&... args)
+ auto log_message(LogLevel level, const std::string_view& format, const Args&... args) -> void
{
- if (level < m_log_level)
+ if (level < m_log_level)
return;
std::lock_guard<std::mutex> lock(m_mutex);
std::string message = format_string(format, args...);
std::string full_message = get_time_stamp() + " [" + get_log_level_string(level) + "] " + message;
-
- if (m_console_output)
+
+ if (m_console_output)
{
set_console_color(level);
std::cout << full_message << std::endl;
reset_console_color();
}
-
- if (m_file_output && m_log_file.is_open())
+
+ if (m_file_output && m_log_file.is_open())
{
m_log_file << full_message << std::endl;
m_log_file.flush();
@@ -91,44 +94,42 @@ namespace Donut
}
template<typename... Args>
- std::string format_string(const std::string_view& format, const Args&... args)
+ auto format_string(const std::string_view& format, const Args&... args) -> std::string
{
std::string result = format.data();
std::vector<std::string> arg_strings = { to_string(args)... };
-
+
size_t arg_index = 0;
size_t pos = 0;
-
+
while ((pos = result.find("{}", pos)) != std::string::npos && arg_index < arg_strings.size())
{
result.replace(pos, 2, arg_strings[arg_index]);
pos += arg_strings[arg_index].length();
arg_index++;
}
-
+
return result;
}
template<typename T>
- std::string to_string(const T& value)
+ auto to_string(const T& value) -> std::string
{
std::stringstream ss;
ss << value;
return ss.str();
}
- void set_log_level(LogLevel level) { m_log_level = level; }
- void enable_console_output(bool enable) { m_console_output = enable; }
- void enable_file_output(bool enable) { m_file_output = enable; }
- void set_log_file(const std::string& filename);
- public:
- Logger();
- ~Logger();
+ auto set_log_level(LogLevel level) -> void { m_log_level = level; }
+ auto enable_console_output(bool enable) -> void { m_console_output = enable; }
+ auto enable_file_output(bool enable) -> void { m_file_output = enable; }
+ auto set_log_file(const std::string& filename) -> void;
+
+ auto get_time_stamp() -> std::string;
+ auto get_log_level_string(LogLevel level) -> std::string;
+ auto set_console_color(LogLevel level) -> void;
+ auto reset_console_color() -> void;
- std::string get_time_stamp();
- std::string get_log_level_string(LogLevel level);
- void set_console_color(LogLevel level);
- void reset_console_color();
private:
LogLevel m_log_level;
bool m_console_output;
diff --git a/src/core/memory.h b/src/core/memory.h
index cbfbe82..3240c71 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -2,22 +2,22 @@
#include <memory>
-namespace Donut
+namespace Donut
{
template<typename T>
using Ref = std::shared_ptr<T>;
- template<typename T>
+ template<typename T>
using Scope = std::unique_ptr<T>;
-
- template<typename T, typename ... Args>
- constexpr Scope<T> create_scope(Args&& ... args)
+
+ template<typename T, typename ... Args>
+ constexpr auto create_scope(Args&& ... args) -> Scope<T>
{
return std::make_unique<T>(std::forward<Args>(args)...);
}
-
+
template<typename T, typename ... Args>
- constexpr Ref<T> create_ref(Args&& ... args)
+ constexpr auto create_ref(Args&& ... args) -> Ref<T>
{
return std::make_shared<T>(std::forward<Args>(args)...);
}
diff --git a/src/core/settings_manager.cpp b/src/core/settings_manager.cpp
index 77f365e..ca4cac5 100644
--- a/src/core/settings_manager.cpp
+++ b/src/core/settings_manager.cpp
@@ -12,7 +12,7 @@ namespace Donut
Settings SettingsManager::s_settings;
bool SettingsManager::s_initialized = false;
- void SettingsManager::initialize()
+ auto SettingsManager::initialize() -> void
{
if (s_initialized)
return;
@@ -22,7 +22,7 @@ namespace Donut
DONUT_INFO("Settings Manager initialized");
}
- void SettingsManager::shutdown()
+ auto SettingsManager::shutdown() -> void
{
if (!s_initialized)
return;
@@ -32,7 +32,7 @@ namespace Donut
DONUT_INFO("Settings Manager shutdown");
}
- void SettingsManager::load_settings()
+ auto SettingsManager::load_settings() -> void
{
std::string file_path = get_settings_file_path();
@@ -105,7 +105,7 @@ namespace Donut
}
}
- void SettingsManager::save_settings()
+ auto SettingsManager::save_settings() -> void
{
std::string file_path = get_settings_file_path();
@@ -158,24 +158,24 @@ namespace Donut
}
}
- void SettingsManager::set_simulation_settings(const SimulationSettings& settings)
+ auto SettingsManager::set_simulation_settings(const SimulationSettings& settings) -> void
{
s_settings.simulation = settings;
save_settings();
}
- void SettingsManager::set_graphics_settings(const GraphicsSettings& settings)
+ auto SettingsManager::set_graphics_settings(const GraphicsSettings& settings) -> void
{
s_settings.graphics = settings;
save_settings();
}
- std::string SettingsManager::get_settings_file_path()
+ auto SettingsManager::get_settings_file_path() -> std::string
{
return "config/settings.toml";
}
- void SettingsManager::load_default_settings()
+ auto SettingsManager::load_default_settings() -> void
{
s_settings.simulation.target_fps = 60;
s_settings.simulation.compute_height = 512;
diff --git a/src/core/settings_manager.h b/src/core/settings_manager.h
index 44a4bcf..95826c7 100644
--- a/src/core/settings_manager.h
+++ b/src/core/settings_manager.h
@@ -7,28 +7,28 @@ namespace Donut
{
struct SimulationSettings
{
- int target_fps = 60;
- int compute_height = 512;
+ int target_fps = 60;
+ int compute_height = 512;
int max_steps_moving = 30000;
int max_steps_static = 15000;
float early_exit_distance = 5e12f;
- bool gravity_enabled = true;
- float disk_thickness = 0.1f;
- float disk_density = 0.1f;
- float rotation_speed = 1.0f;
- float blur_strength = 2.0f;
- float glow_intensity = 0.1f;
+ bool gravity_enabled = true;
+ float disk_thickness = 0.1f;
+ float disk_density = 0.1f;
+ float rotation_speed = 1.0f;
+ float blur_strength = 2.0f;
+ float glow_intensity = 0.1f;
};
struct GraphicsSettings
{
- std::string render_api = "OpenGL";
+ std::string render_api = "OpenGL";
bool v_sync_enabled = true;
- bool show_fps = true;
+ bool show_fps = true;
bool show_performance_metrics = true;
bool show_debug_info = false;
bool enable_anti_aliasing = true;
- std::string selected_theme = "Dark";
+ std::string selected_theme = "Dark";
};
struct Settings
@@ -40,39 +40,41 @@ namespace Donut
class SettingsManager
{
public:
- static void initialize();
- static void shutdown();
-
- static void load_settings();
- static void save_settings();
-
- static Settings& get_settings() { return s_settings; }
- static const Settings& get_settings_const() { return s_settings; }
-
- static void set_simulation_settings(const SimulationSettings& settings);
- static void set_graphics_settings(const GraphicsSettings& settings);
+ static auto initialize() -> void;
+ static auto shutdown() -> void;
+
+ static auto load_settings() -> void;
+ static auto save_settings() -> void;
+
+ static auto get_settings() -> Settings& { return s_settings; }
+ static auto get_settings_const() -> const Settings& { return s_settings; }
+
+ static auto set_simulation_settings(const SimulationSettings& settings) -> void;
+ static auto set_graphics_settings(const GraphicsSettings& settings) -> void;
+
+ static auto get_target_fps() -> int { return s_settings.simulation.target_fps; }
+ static auto get_compute_height() -> int { return s_settings.simulation.compute_height; }
+ static auto get_max_steps_moving() -> int { return s_settings.simulation.max_steps_moving; }
+ static auto get_max_steps_static() -> int { return s_settings.simulation.max_steps_static; }
+ static auto get_early_exit_distance() -> float { return s_settings.simulation.early_exit_distance; }
+ static auto get_gravity_enabled() -> bool { return s_settings.simulation.gravity_enabled; }
+ static auto get_disk_thickness() -> float { return s_settings.simulation.disk_thickness; }
+ static auto get_disk_density() -> float { return s_settings.simulation.disk_density; }
+ static auto get_rotation_speed() -> float { return s_settings.simulation.rotation_speed; }
+ static auto get_blur_strength() -> float { return s_settings.simulation.blur_strength; }
+ static auto get_glow_intensity() -> float { return s_settings.simulation.glow_intensity; }
+ static auto get_render_api() -> std::string { return s_settings.graphics.render_api; }
+ static auto get_v_sync_enabled() -> bool { return s_settings.graphics.v_sync_enabled; }
+ static auto get_show_fps() -> bool { return s_settings.graphics.show_fps; }
+ static auto get_show_performance_metrics() -> bool { return s_settings.graphics.show_performance_metrics; }
+ static auto get_show_debug_info() -> bool { return s_settings.graphics.show_debug_info; }
+ static auto get_enable_anti_aliasing() -> bool { return s_settings.graphics.enable_anti_aliasing; }
+ static auto get_selected_theme() -> std::string { return s_settings.graphics.selected_theme; }
- static int get_target_fps() { return s_settings.simulation.target_fps; }
- static int get_compute_height() { return s_settings.simulation.compute_height; }
- static int get_max_steps_moving() { return s_settings.simulation.max_steps_moving; }
- static int get_max_steps_static() { return s_settings.simulation.max_steps_static; }
- static float get_early_exit_distance() { return s_settings.simulation.early_exit_distance; }
- static bool get_gravity_enabled() { return s_settings.simulation.gravity_enabled; }
- static float get_disk_thickness() { return s_settings.simulation.disk_thickness; }
- static float get_disk_density() { return s_settings.simulation.disk_density; }
- static float get_rotation_speed() { return s_settings.simulation.rotation_speed; }
- static float get_blur_strength() { return s_settings.simulation.blur_strength; }
- static float get_glow_intensity() { return s_settings.simulation.glow_intensity; }
- static std::string get_render_api() { return s_settings.graphics.render_api; }
- static bool get_v_sync_enabled() { return s_settings.graphics.v_sync_enabled; }
- static bool get_show_fps() { return s_settings.graphics.show_fps; }
- static bool get_show_performance_metrics() { return s_settings.graphics.show_performance_metrics; }
- static bool get_show_debug_info() { return s_settings.graphics.show_debug_info; }
- static bool get_enable_anti_aliasing() { return s_settings.graphics.enable_anti_aliasing; }
- static std::string get_selected_theme() { return s_settings.graphics.selected_theme; }
private:
- static std::string get_settings_file_path();
- static void load_default_settings();
+ static auto get_settings_file_path() -> std::string;
+ static auto load_default_settings() -> void;
+
private:
static Settings s_settings;
static bool s_initialized;
diff --git a/src/core/state.h b/src/core/state.h
index f4fe9b3..623f1c2 100644
--- a/src/core/state.h
+++ b/src/core/state.h
@@ -8,12 +8,12 @@ namespace Donut
{
public:
virtual ~State() = default;
-
- virtual void on_enter() = 0;
- virtual void on_exit() = 0;
- virtual void on_update(float delta_time) = 0;
- virtual void on_render() = 0;
- virtual void on_im_ui_render() = 0;
- virtual void on_event(Event& event) = 0;
+
+ virtual auto on_enter() -> void = 0;
+ virtual auto on_exit() -> void = 0;
+ virtual auto on_update(float delta_time) -> void = 0;
+ virtual auto on_render() -> void = 0;
+ virtual auto on_im_ui_render() -> void = 0;
+ virtual auto on_event(Event& event) -> void = 0;
};
};
diff --git a/src/core/state_manager.cpp b/src/core/state_manager.cpp
index 5086ddd..8018401 100644
--- a/src/core/state_manager.cpp
+++ b/src/core/state_manager.cpp
@@ -3,23 +3,23 @@
namespace Donut
{
- void StateManager::shutdown()
+ auto StateManager::shutdown() -> void
{
if (m_current_state)
m_current_state->on_exit();
-
+
destroy_states();
DONUT_INFO("StateManager shutdown");
}
- void StateManager::destroy_states()
+ auto StateManager::destroy_states() -> void
{
m_states.clear();
m_current_state = nullptr;
m_current_state_name = "";
}
- void StateManager::register_state(const std::string& state_name, Scope<State> state)
+ auto StateManager::register_state(const std::string& state_name, Scope<State> state) -> void
{
if (m_states.find(state_name) != m_states.end())
DONUT_WARN("State '{}' already exists, overwriting", state_name);
@@ -27,7 +27,7 @@ namespace Donut
DONUT_INFO("Registered state: {}", state_name);
}
- void StateManager::switch_to_state(const std::string& state_name)
+ auto StateManager::switch_to_state(const std::string& state_name) -> void
{
auto it = m_states.find(state_name);
if (it == m_states.end())
@@ -49,7 +49,7 @@ namespace Donut
DONUT_INFO("Switched to state: {}", state_name);
}
- State* StateManager::get_state(const std::string& state_name)
+ auto StateManager::get_state(const std::string& state_name) -> State*
{
auto it = m_states.find(state_name);
if (it != m_states.end())
@@ -57,30 +57,30 @@ namespace Donut
return nullptr;
}
- bool StateManager::has_state(const std::string& state_name) const
+ auto StateManager::has_state(const std::string& state_name) const -> bool
{
return m_states.find(state_name) != m_states.end();
}
- void StateManager::update(float delta_time)
+ auto StateManager::update(float delta_time) -> void
{
if (m_current_state)
m_current_state->on_update(delta_time);
}
- void StateManager::render()
+ auto StateManager::render() -> void
{
if (m_current_state)
m_current_state->on_render();
}
- void StateManager::on_im_ui_render()
+ auto StateManager::on_im_ui_render() -> void
{
if (m_current_state)
m_current_state->on_im_ui_render();
}
- void StateManager::on_event(Event& event)
+ auto StateManager::on_event(Event& event) -> void
{
if (m_current_state)
m_current_state->on_event(event);
diff --git a/src/core/state_manager.h b/src/core/state_manager.h
index 584df11..446841e 100644
--- a/src/core/state_manager.h
+++ b/src/core/state_manager.h
@@ -12,29 +12,30 @@ namespace Donut
{
public:
~StateManager() = default;
- void shutdown();
-
- void update(float delta_time);
- void render();
- void on_im_ui_render();
- void on_event(Event& event);
-
- void register_state(const std::string& state_name, Scope<State> state);
- void switch_to_state(const std::string& state_name);
+ auto shutdown() -> void;
+
+ auto update(float delta_time) -> void;
+ auto render() -> void;
+ auto on_im_ui_render() -> void;
+ auto on_event(Event& event) -> void;
+
+ auto register_state(const std::string& state_name, Scope<State> state) -> void;
+ auto switch_to_state(const std::string& state_name) -> void;
+
+ auto get_current_state_name() const -> std::string { return m_current_state_name; }
+ auto get_current_state() const -> State* { return m_current_state; }
+
+ auto get_state(const std::string& state_name) -> State*;
+ auto has_state(const std::string& state_name) const -> bool;
- std::string get_current_state_name() const { return m_current_state_name; }
- State* get_current_state() const { return m_current_state; }
-
- State* get_state(const std::string& state_name);
- bool has_state(const std::string& state_name) const;
private:
- void create_states();
- void destroy_states();
+ auto create_states() -> void;
+ auto destroy_states() -> void;
private:
- State* m_current_state = nullptr;
+ State* m_current_state = nullptr;
std::string m_current_state_name = "";
-
+
std::unordered_map<std::string, Scope<State>> m_states;
};
}
diff --git a/src/core/theme_manager.cpp b/src/core/theme_manager.cpp
index db48e12..4ae025f 100644
--- a/src/core/theme_manager.cpp
+++ b/src/core/theme_manager.cpp
@@ -4,7 +4,7 @@ namespace Donut
{
Theme ThemeManager::s_current_theme = Theme::Dark;
- void ThemeManager::set_theme(Theme theme)
+ auto ThemeManager::set_theme(Theme theme) -> void
{
s_current_theme = theme;
@@ -22,7 +22,7 @@ namespace Donut
}
}
- void ThemeManager::apply_dark_theme()
+ auto ThemeManager::apply_dark_theme() -> void
{
ImGuiStyle& style = ImGui::GetStyle();
ImVec4* colors = style.Colors;
@@ -111,7 +111,7 @@ namespace Donut
style.DisabledAlpha = 0.6f;
}
- void ThemeManager::apply_light_theme()
+ auto ThemeManager::apply_light_theme() -> void
{
ImGuiStyle& style = ImGui::GetStyle();
ImVec4* colors = style.Colors;
@@ -200,7 +200,7 @@ namespace Donut
style.DisabledAlpha = 0.6f;
}
- void ThemeManager::apply_blue_theme()
+ auto ThemeManager::apply_blue_theme() -> void
{
ImGuiStyle& style = ImGui::GetStyle();
ImVec4* colors = style.Colors;
diff --git a/src/core/theme_manager.h b/src/core/theme_manager.h
index 7c1a295..d067906 100644
--- a/src/core/theme_manager.h
+++ b/src/core/theme_manager.h
@@ -14,13 +14,13 @@ namespace Donut
class ThemeManager
{
public:
- static void set_theme(Theme theme);
- static Theme get_current_theme() { return s_current_theme; }
-
- static void apply_dark_theme();
- static void apply_light_theme();
- static void apply_blue_theme();
-
+ static auto set_theme(Theme theme) -> void;
+ static auto get_current_theme() -> Theme { return s_current_theme; }
+
+ static auto apply_dark_theme() -> void;
+ static auto apply_light_theme() -> void;
+ static auto apply_blue_theme() -> void;
+
private:
static Theme s_current_theme;
};
diff --git a/src/core/window.cpp b/src/core/window.cpp
index 0a9ac8b..619d7e1 100644
--- a/src/core/window.cpp
+++ b/src/core/window.cpp
@@ -15,7 +15,7 @@ namespace Donut
static uint32_t s_glfw_window_count = 0;
Window::Window(const std::string& title, int width, int height)
- : m_title(title), m_width(width),
+ : m_title(title), m_width(width),
m_height(height), m_is_closed(false)
{
init();
@@ -26,10 +26,10 @@ namespace Donut
shutdown();
}
- void Window::init()
+ auto Window::init() -> void
{
DONUT_INFO("Initializing window: ", m_title, " (", m_width, "x", m_height, ")");
-
+
if (!s_glfw_initialized)
{
int success = glfwInit();
@@ -64,7 +64,7 @@ namespace Donut
glfwTerminate();
return;
}
-
+
DONUT_INFO("GLFW window created successfully");
if (RendererAPI::get_api() != RendererAPI::API::Vulkan)
@@ -85,12 +85,12 @@ namespace Donut
s_glfw_window_count++;
}
- void Window::shutdown()
+ auto Window::shutdown() -> void
{
DONUT_INFO("Shutting down window: ", m_title);
-
+
shutdown_im_gui();
-
+
glfwDestroyWindow(m_window);
s_glfw_window_count--;
@@ -102,33 +102,33 @@ namespace Donut
}
}
- void Window::on_update() const
+ auto Window::on_update() const -> void
{
glfwPollEvents();
if (RendererAPI::get_api() != RendererAPI::API::Vulkan)
glfwSwapBuffers(m_window);
}
- bool Window::should_close() const
+ auto Window::should_close() const -> bool
{
return glfwWindowShouldClose(m_window) || m_is_closed;
}
- void Window::set_cursor_locked(bool locked)
+ auto Window::set_cursor_locked(bool locked) -> void
{
m_cursor_locked = locked;
- glfwSetInputMode(m_window, GLFW_CURSOR, locked ?
+ glfwSetInputMode(m_window, GLFW_CURSOR, locked ?
GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
}
- void Window::set_cursor_visible(bool visible)
+ auto Window::set_cursor_visible(bool visible) -> void
{
m_cursor_visible = visible;
- glfwSetInputMode(m_window, GLFW_CURSOR, visible ?
+ glfwSetInputMode(m_window, GLFW_CURSOR, visible ?
GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN);
}
- void Window::init_im_gui()
+ auto Window::init_im_gui() -> void
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
@@ -155,15 +155,15 @@ namespace Donut
#else
ImGui_ImplOpenGL3_Init("#version 130");
#endif
-
+
DONUT_INFO("ImGUI initialized successfully");
}
- void Window::setup_im_gui_fonts()
+ auto Window::setup_im_gui_fonts() -> void
{
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
-
+
m_main_font = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Regular.ttf", 16.0f);
if (!m_main_font)
{
@@ -172,36 +172,36 @@ namespace Donut
}
else
DONUT_INFO("Successfully loaded Inter font");
-
+
m_large_font = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Bold.ttf", 20.0f);
if (!m_large_font)
m_large_font = m_main_font;
-
+
m_small_font = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Light.ttf", 12.0f);
if (!m_small_font)
m_small_font = m_main_font;
-
+
io.FontDefault = m_main_font;
DONUT_INFO("ImGUI fonts loaded successfully");
}
- void Window::shutdown_im_gui()
+ auto Window::shutdown_im_gui() -> void
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
-
+
DONUT_INFO("ImGUI shutdown");
}
- void Window::begin_im_gui_frame()
+ auto Window::begin_im_gui_frame() -> void
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
- void Window::end_im_gui_frame()
+ auto Window::end_im_gui_frame() -> void
{
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
@@ -216,32 +216,32 @@ namespace Donut
}
}
- void Window::glfw_error_callback(int error, const char* description)
+ auto Window::glfw_error_callback(int error, const char* description) -> void
{
DONUT_ERROR("GLFW Error ({}): {}", error, description ? description : "");
}
- void Window::glfw_window_close_callback(GLFWwindow* window)
+ auto Window::glfw_window_close_callback(GLFWwindow* window) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
WindowCloseEvent event;
win->m_event_handler.on_event(event);
}
- void Window::glfw_window_size_callback(GLFWwindow* window, int width, int height)
+ auto Window::glfw_window_size_callback(GLFWwindow* window, int width, int height) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
win->m_width = width;
win->m_height = height;
-
+
WindowResizeEvent event(width, height);
win->m_event_handler.on_event(event);
}
- void Window::glfw_window_focus_callback(GLFWwindow* window, int focused)
+ auto Window::glfw_window_focus_callback(GLFWwindow* window, int focused) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
-
+
if (focused)
{
WindowFocusEvent event;
@@ -254,18 +254,18 @@ namespace Donut
}
}
- void Window::glfw_window_pos_callback(GLFWwindow* window, int xpos, int ypos)
+ auto Window::glfw_window_pos_callback(GLFWwindow* window, int xpos, int ypos) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
WindowMovedEvent event(xpos, ypos);
win->m_event_handler.on_event(event);
}
- void Window::glfw_key_callback(GLFWwindow* window, int key, int scancode,
- int action, int mods)
+ auto Window::glfw_key_callback(GLFWwindow* window, int key, int scancode,
+ int action, int mods) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
-
+
switch (action)
{
case GLFW_PRESS:
@@ -286,18 +286,18 @@ namespace Donut
}
}
- void Window::glfw_char_callback(GLFWwindow* window, unsigned int keycode)
+ auto Window::glfw_char_callback(GLFWwindow* window, unsigned int keycode) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
KeyTypedEvent event(keycode);
win->m_event_handler.on_event(event);
}
- void Window::glfw_mouse_button_callback(GLFWwindow* window, int button,
- int action, int mods)
+ auto Window::glfw_mouse_button_callback(GLFWwindow* window, int button,
+ int action, int mods) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
-
+
switch (action)
{
case GLFW_PRESS:
@@ -313,14 +313,14 @@ namespace Donut
}
}
- void Window::glfw_mouse_scroll_callback(GLFWwindow* window, double x_offset, double y_offset)
+ auto Window::glfw_mouse_scroll_callback(GLFWwindow* window, double x_offset, double y_offset) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
MouseScrolledEvent event((float)x_offset, (float)y_offset);
win->m_event_handler.on_event(event);
}
- void Window::glfw_cursor_pos_callback(GLFWwindow* window, double x_pos, double y_pos)
+ auto Window::glfw_cursor_pos_callback(GLFWwindow* window, double x_pos, double y_pos) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
MouseMovedEvent event((float)x_pos, (float)y_pos);
diff --git a/src/core/window.h b/src/core/window.h
index 92842ba..9b7d7b9 100644
--- a/src/core/window.h
+++ b/src/core/window.h
@@ -18,46 +18,48 @@ namespace Donut
Window(const std::string& title, int width, int height);
~Window();
- bool should_close() const;
- void on_update() const;
+ auto should_close() const -> bool;
+ auto on_update() const -> void;
- void set_event_callback(const EventCallbackFn& callback)
+ auto set_event_callback(const EventCallbackFn& callback) -> void
{
m_event_handler.set_event_callback(callback);
}
- EventHandler& get_event_handler() { return m_event_handler; }
+ auto get_event_handler() -> EventHandler& { return m_event_handler; }
- unsigned int get_width() const { return m_width; }
- unsigned int get_height() const { return m_height; }
+ auto get_width() const -> unsigned int { return m_width; }
+ auto get_height() const -> unsigned int { return m_height; }
- void* get_native_window() const { return m_window; }
+ auto get_native_window() const -> void* { return m_window; }
+
+ auto set_cursor_locked(bool locked) -> void;
+ auto set_cursor_visible(bool visible) -> void;
+ auto is_cursor_locked() const -> bool { return m_cursor_locked; }
+ auto is_cursor_visible() const -> bool { return m_cursor_visible; }
+
+ auto init_im_gui() -> void;
+ auto begin_im_gui_frame() -> void;
+ auto end_im_gui_frame() -> void;
- void set_cursor_locked(bool locked);
- void set_cursor_visible(bool visible);
- bool is_cursor_locked() const { return m_cursor_locked; }
- bool is_cursor_visible() const { return m_cursor_visible; }
-
- void init_im_gui();
- void begin_im_gui_frame();
- void end_im_gui_frame();
private:
- void init();
- void shutdown();
+ auto init() -> void;
+ auto shutdown() -> void;
+
+ auto setup_im_gui_fonts() -> void;
+ auto shutdown_im_gui() -> void;
+
+ static auto glfw_error_callback(int error, const char* description) -> void;
+ static auto glfw_window_close_callback(GLFWwindow* window) -> void;
+ static auto glfw_window_size_callback(GLFWwindow* window, int width, int height) -> void;
+ static auto glfw_window_focus_callback(GLFWwindow* window, int focused) -> void;
+ static auto glfw_window_pos_callback(GLFWwindow* window, int xpos, int ypos) -> void;
+ static auto glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) -> void;
+ static auto glfw_char_callback(GLFWwindow* window, unsigned int keycode) -> void;
+ static auto glfw_mouse_button_callback(GLFWwindow* window, int button, int action, int mods) -> void;
+ static auto glfw_mouse_scroll_callback(GLFWwindow* window, double x_offset, double y_offset) -> void;
+ static auto glfw_cursor_pos_callback(GLFWwindow* window, double x_pos, double y_pos) -> void;
- void setup_im_gui_fonts();
- void shutdown_im_gui();
-
- static void glfw_error_callback(int error, const char* description);
- static void glfw_window_close_callback(GLFWwindow* window);
- static void glfw_window_size_callback(GLFWwindow* window, int width, int height);
- static void glfw_window_focus_callback(GLFWwindow* window, int focused);
- static void glfw_window_pos_callback(GLFWwindow* window, int xpos, int ypos);
- static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
- static void glfw_char_callback(GLFWwindow* window, unsigned int keycode);
- static void glfw_mouse_button_callback(GLFWwindow* window, int button, int action, int mods);
- static void glfw_mouse_scroll_callback(GLFWwindow* window, double x_offset, double y_offset);
- static void glfw_cursor_pos_callback(GLFWwindow* window, double x_pos, double y_pos);
private:
GLFWwindow* m_window;
EventHandler m_event_handler;
@@ -68,7 +70,7 @@ namespace Donut
bool m_is_closed;
bool m_cursor_locked = false;
bool m_cursor_visible = true;
-
+
ImFont* m_main_font = nullptr;
ImFont* m_small_font = nullptr;
ImFont* m_large_font = nullptr;