build: fix compilation on Windows
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
light7734 2025-07-17 18:11:53 +03:30
parent dac89f64ce
commit bd5196a9c9
No known key found for this signature in database
GPG key ID: 195E37E1A0C88275
2 changed files with 26 additions and 26 deletions

View file

@ -16,18 +16,23 @@ public:
~wWindow() override; ~wWindow() override;
wWindow(wWindow &&) = delete;
wWindow(const wWindow &) = delete;
auto operator=(wWindow &&) -> wWindow & = delete;
auto operator=(const wWindow &) -> wWindow & = delete;
void poll_events() override; void poll_events() override;
void on_event(const Event &event) override; void on_event(const Event &event) override;
void set_properties( void set_properties(const Properties &properties, bool overrideVisibility = false) override;
const WindowProperties &properties,
bool overrideVisibility = false
) override;
void set_title(const std::string &title) override; void set_title(const std::string &title) override;
void set_size(const glm::uvec2 &size, bool additive = false) override; void set_size(const math::uvec2 &size) override;
void set_v_sync(bool vsync, bool toggle = false) override; void set_v_sync(bool vsync, bool toggle = false) override;
@ -39,13 +44,17 @@ public:
} }
private: private:
void on_window_resize(const WindowResizedEvent &event);
void bind_glfw_events();
GLFWwindow *m_handle { nullptr }; GLFWwindow *m_handle { nullptr };
std::function<void(Event &)> m_event_callback; std::function<void(Event &)> m_event_callback;
void on_window_resize(const WindowResizedEvent &event); Properties m_properties {};
void bind_glfw_events(); bool b_Closed {};
}; };
} // namespace lt } // namespace lt

View file

@ -8,9 +8,7 @@
namespace lt { namespace lt {
Window::~Window() Window::~Window() = default;
{
}
auto Window::create(const std::function<void(Event &)> &callback) -> Scope<Window> auto Window::create(const std::function<void(Event &)> &callback) -> Scope<Window>
{ {
@ -20,17 +18,16 @@ auto Window::create(const std::function<void(Event &)> &callback) -> Scope<Windo
wWindow::wWindow(std::function<void(Event &)> callback) wWindow::wWindow(std::function<void(Event &)> callback)
: m_event_callback(std::move(std::move(callback))) : m_event_callback(std::move(std::move(callback)))
{ {
// init glfw ensure(glfwInit(), "Failed to initialize 'glfw'");
ensure(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'");
// create window
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
ensure(m_handle, "wWindow::wWindow: failed to create 'GLFWwindow'"); ensure(m_handle, "Failed to create 'GLFWwindow'");
glfwSetWindowUserPointer(m_handle, &m_event_callback); glfwSetWindowUserPointer(m_handle, &m_event_callback);
bind_glfw_events(); bind_glfw_events();
@ -57,6 +54,8 @@ void wWindow::on_event(const Event &event)
case EventType::WindowResized: case EventType::WindowResized:
on_window_resize(dynamic_cast<const WindowResizedEvent &>(event)); on_window_resize(dynamic_cast<const WindowResizedEvent &>(event));
break; break;
default: break;
} }
} }
@ -65,8 +64,7 @@ void wWindow::on_window_resize(const WindowResizedEvent &event)
m_properties.size = event.get_size(); m_properties.size = event.get_size();
} }
void wWindow:: void wWindow::set_properties(const Properties &properties, bool overrideVisibility /* = false */)
set_properties(const WindowProperties &properties, bool overrideVisibility /* = false */)
{ {
// save the visibility status and re-assign if 'overrideVisibility' is false // save the visibility status and re-assign if 'overrideVisibility' is false
auto visible = overrideVisibility ? properties.visible : m_properties.visible; auto visible = overrideVisibility ? properties.visible : m_properties.visible;
@ -87,17 +85,10 @@ void wWindow::set_title(const std::string &title)
glfwSetWindowTitle(m_handle, title.c_str()); glfwSetWindowTitle(m_handle, title.c_str());
} }
void wWindow::set_size(const glm::uvec2 &size, bool additive /* = false */) void wWindow::set_size(const math::uvec2 &size)
{ {
m_properties.size.x = size.x == 0u ? m_properties.size.x : m_properties.size = size;
additive ? m_properties.size.x + size.x : glfwSetWindowSize(m_handle, static_cast<int>(size.x), static_cast<int>(size.y));
size.x;
m_properties.size.y = size.y == 0u ? m_properties.size.y :
additive ? m_properties.size.y + size.y :
size.y;
glfwSetWindowSize(m_handle, size.x, size.y);
} }
void wWindow::set_v_sync(bool vsync, bool toggle /* = false */) void wWindow::set_v_sync(bool vsync, bool toggle /* = false */)