Browse Source

Engine: Rename getWindow() => window()

master
Riyyi 2 years ago
parent
commit
aec1a80623
  1. 2
      src/inferno/application.h
  2. 10
      src/inferno/io/input.cpp
  3. 4
      src/inferno/system/camerasystem.cpp
  4. 4
      src/inferno/system/textareasystem.cpp
  5. 2
      src/inferno/window.cpp

2
src/inferno/application.h

@ -38,7 +38,7 @@ public:
inline void setStatus(int status) { m_status = status; } 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; } static Application& the() { return *s_instance; }

10
src/inferno/io/input.cpp

@ -23,8 +23,8 @@ float Input::m_yOffset = 0.0f;
void Input::initialize() void Input::initialize()
{ {
// Set cursor in the middle of the screen // Set cursor in the middle of the screen
m_xPosLast = Application::the().getWindow().getWidth() / 2.0f; m_xPosLast = Application::the().window().getWidth() / 2.0f;
m_yPosLast = Application::the().getWindow().getHeight() / 2.0f; m_yPosLast = Application::the().window().getHeight() / 2.0f;
ruc::info("Input initialized"); ruc::info("Input initialized");
} }
@ -56,19 +56,19 @@ bool Input::onMousePosition(MousePositionEvent& e)
bool Input::isKeyPressed(int key) bool Input::isKeyPressed(int key)
{ {
GLFWwindow* w = Application::the().getWindow().getWindow(); GLFWwindow* w = Application::the().window().getWindow();
return glfwGetKey(w, key) == GLFW_PRESS; return glfwGetKey(w, key) == GLFW_PRESS;
} }
bool Input::isMouseButtonPressed(int button) bool Input::isMouseButtonPressed(int button)
{ {
GLFWwindow* w = Application::the().getWindow().getWindow(); GLFWwindow* w = Application::the().window().getWindow();
return glfwGetMouseButton(w, button) == GLFW_PRESS; return glfwGetMouseButton(w, button) == GLFW_PRESS;
} }
std::pair<float, float> Input::getMousePosition() std::pair<float, float> Input::getMousePosition()
{ {
GLFWwindow* w = Application::the().getWindow().getWindow(); GLFWwindow* w = Application::the().window().getWindow();
double xPos; double xPos;
double yPos; double yPos;
glfwGetCursorPos(w, &xPos, &yPos); glfwGetCursorPos(w, &xPos, &yPos);

4
src/inferno/system/camerasystem.cpp

@ -69,7 +69,7 @@ void CameraSystem::updateOrthographic(TransformComponent& transform, CameraCompo
transform.transform = { glm::inverse(transform.transform) }; transform.transform = { glm::inverse(transform.transform) };
// View space -> Clip space: projection matrix // View space -> Clip space: projection matrix
float aspectRatio = Application::the().getWindow().getAspect(); float aspectRatio = Application::the().window().getAspect();
camera.projection = { camera.projection = {
glm::ortho(-aspectRatio * camera.zoomLevel, aspectRatio * camera.zoomLevel, glm::ortho(-aspectRatio * camera.zoomLevel, aspectRatio * camera.zoomLevel,
-camera.zoomLevel, camera.zoomLevel, -1.0f, 1.0f) -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) }; transform.transform = { glm::lookAt(transform.translate, transform.translate + transform.rotate, camera.up) };
// View space -> Clip space: projection matrix // 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) }; camera.projection = { glm::perspective(glm::radians(camera.fov), aspect, NEAR_PLANE, FAR_PLANE) };
// Clip space -> Screen space: viewport transform // Clip space -> Screen space: viewport transform

4
src/inferno/system/textareasystem.cpp

@ -32,8 +32,8 @@ void TextAreaSystem::render()
auto view = m_scene->registry()->view<TransformComponent, TextAreaComponent>(); auto view = m_scene->registry()->view<TransformComponent, TextAreaComponent>();
glm::ivec2 viewport = { glm::ivec2 viewport = {
Application::the().getWindow().getWidth(), Application::the().window().getWidth(),
Application::the().getWindow().getHeight(), Application::the().window().getHeight(),
}; };
for (auto [entity, transform, textarea] : view.each()) { for (auto [entity, transform, textarea] : view.each()) {

2
src/inferno/window.cpp

@ -214,7 +214,7 @@ void Window::signalCallback(int signal)
if (signal == SIGINT || signal == SIGTERM) { if (signal == SIGINT || signal == SIGTERM) {
WindowCloseEvent e; WindowCloseEvent e;
Application::the().getWindow().m_eventCallback(e); Application::the().window().m_eventCallback(e);
} }
} }

Loading…
Cancel
Save