From aec1a80623d71b9f74a76df6356b9d928c3b6fbc Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 26 Sep 2022 14:18:34 +0200 Subject: [PATCH] Engine: Rename getWindow() => window() --- src/inferno/application.h | 2 +- src/inferno/io/input.cpp | 10 +++++----- src/inferno/system/camerasystem.cpp | 4 ++-- src/inferno/system/textareasystem.cpp | 4 ++-- src/inferno/window.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/inferno/application.h b/src/inferno/application.h index f00504b..9663982 100644 --- a/src/inferno/application.h +++ b/src/inferno/application.h @@ -38,7 +38,7 @@ public: inline void setStatus(int status) { m_status = status; } - inline Window& getWindow() const { return *m_window; } + inline Window& window() const { return *m_window; } static Application& the() { return *s_instance; } diff --git a/src/inferno/io/input.cpp b/src/inferno/io/input.cpp index 24e7b6a..a345b22 100644 --- a/src/inferno/io/input.cpp +++ b/src/inferno/io/input.cpp @@ -23,8 +23,8 @@ float Input::m_yOffset = 0.0f; void Input::initialize() { // Set cursor in the middle of the screen - m_xPosLast = Application::the().getWindow().getWidth() / 2.0f; - m_yPosLast = Application::the().getWindow().getHeight() / 2.0f; + m_xPosLast = Application::the().window().getWidth() / 2.0f; + m_yPosLast = Application::the().window().getHeight() / 2.0f; ruc::info("Input initialized"); } @@ -56,19 +56,19 @@ bool Input::onMousePosition(MousePositionEvent& e) bool Input::isKeyPressed(int key) { - GLFWwindow* w = Application::the().getWindow().getWindow(); + GLFWwindow* w = Application::the().window().getWindow(); return glfwGetKey(w, key) == GLFW_PRESS; } bool Input::isMouseButtonPressed(int button) { - GLFWwindow* w = Application::the().getWindow().getWindow(); + GLFWwindow* w = Application::the().window().getWindow(); return glfwGetMouseButton(w, button) == GLFW_PRESS; } std::pair Input::getMousePosition() { - GLFWwindow* w = Application::the().getWindow().getWindow(); + GLFWwindow* w = Application::the().window().getWindow(); double xPos; double yPos; glfwGetCursorPos(w, &xPos, &yPos); diff --git a/src/inferno/system/camerasystem.cpp b/src/inferno/system/camerasystem.cpp index d3d7d42..049b58d 100644 --- a/src/inferno/system/camerasystem.cpp +++ b/src/inferno/system/camerasystem.cpp @@ -69,7 +69,7 @@ void CameraSystem::updateOrthographic(TransformComponent& transform, CameraCompo transform.transform = { glm::inverse(transform.transform) }; // View space -> Clip space: projection matrix - float aspectRatio = Application::the().getWindow().getAspect(); + float aspectRatio = Application::the().window().getAspect(); camera.projection = { glm::ortho(-aspectRatio * camera.zoomLevel, aspectRatio * camera.zoomLevel, -camera.zoomLevel, camera.zoomLevel, -1.0f, 1.0f) @@ -90,7 +90,7 @@ void CameraSystem::updatePerspective(TransformComponent& transform, CameraCompon transform.transform = { glm::lookAt(transform.translate, transform.translate + transform.rotate, camera.up) }; // View space -> Clip space: projection matrix - float aspect = Application::the().getWindow().getAspect(); + float aspect = Application::the().window().getAspect(); camera.projection = { glm::perspective(glm::radians(camera.fov), aspect, NEAR_PLANE, FAR_PLANE) }; // Clip space -> Screen space: viewport transform diff --git a/src/inferno/system/textareasystem.cpp b/src/inferno/system/textareasystem.cpp index 3ac9f95..90bd766 100644 --- a/src/inferno/system/textareasystem.cpp +++ b/src/inferno/system/textareasystem.cpp @@ -32,8 +32,8 @@ void TextAreaSystem::render() auto view = m_scene->registry()->view(); glm::ivec2 viewport = { - Application::the().getWindow().getWidth(), - Application::the().getWindow().getHeight(), + Application::the().window().getWidth(), + Application::the().window().getHeight(), }; for (auto [entity, transform, textarea] : view.each()) { diff --git a/src/inferno/window.cpp b/src/inferno/window.cpp index 9e3c2ce..0a0e960 100644 --- a/src/inferno/window.cpp +++ b/src/inferno/window.cpp @@ -214,7 +214,7 @@ void Window::signalCallback(int signal) if (signal == SIGINT || signal == SIGTERM) { WindowCloseEvent e; - Application::the().getWindow().m_eventCallback(e); + Application::the().window().m_eventCallback(e); } }