hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/core/window.cpp
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 /src/core/window.cpp
parentdce67620b95a9555c7db950196b22f1bb88a307b (diff)
refactor: trailing return types in core
Diffstat (limited to 'src/core/window.cpp')
-rw-r--r--src/core/window.cpp80
1 files changed, 40 insertions, 40 deletions
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);