#pragma once #include #include #include "event.h" namespace Donut { class Window { public: using EventCallbackFn = std::function; Window(const std::string& title, int width, int height); ~Window(); bool should_close() const; void on_update() const; void set_event_callback(const EventCallbackFn& callback) { m_event_handler.set_event_callback(callback); } EventHandler& get_event_handler() { return m_event_handler; } unsigned int get_width() const { return m_width; } unsigned int get_height() const { return m_height; } void* get_native_window() const { return m_window; } private: void init(); void shutdown(); 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; std::string m_title; unsigned int m_width; unsigned int m_height; bool m_is_closed; }; }