55namespace Pathfinder {
66
77#ifdef __ANDROID__
8- Window::Window (const Vec2I& size) : logical_size_ (size) {}
8+ Window::Window (const Vec2I& size) : physical_size_ (size) {}
99#else
10- Window::Window (const Vec2I& size, GLFWwindow* window_handle) : logical_size_ (size), glfw_window_(window_handle) {
10+ Window::Window (const Vec2I& size, GLFWwindow* window_handle) : physical_size_ (size), glfw_window_(window_handle) {
1111 // Assign this to window user, so we can fetch it when window size changes.
1212 glfwSetWindowUserPointer (glfw_window_, this );
1313 glfwSetFramebufferSizeCallback (glfw_window_, framebuffer_resize_callback);
1414}
1515#endif
1616
1717Vec2I Window::get_physical_size () const {
18- return (logical_size_. to_f32 () * dpi_scaling_factor_). to_i32 () ;
18+ return physical_size_ ;
1919}
2020
2121Vec2I Window::get_logical_size () const {
22- return logical_size_ ;
22+ return (physical_size_. to_f32 () / dpi_scaling_factor_). to_i32 () ;
2323}
2424
2525Vec2I Window::get_position () const {
@@ -48,7 +48,7 @@ void Window::set_dpi_scaling_factor(float scale) {
4848
4949#ifndef __ANDROID__
5050void Window::framebuffer_resize_callback (GLFWwindow* glfw_window, int width, int height) {
51- auto window = reinterpret_cast <Window*>(glfwGetWindowUserPointer (glfw_window));
51+ auto window = static_cast <Window*>(glfwGetWindowUserPointer (glfw_window));
5252
5353 if (window) {
5454 // Get the size of window decorations.
@@ -57,11 +57,11 @@ void Window::framebuffer_resize_callback(GLFWwindow* glfw_window, int width, int
5757
5858 // TODO: consider window decorations.
5959 window->just_resized_ = true ;
60- window->logical_size_ = ( Vec2F ( width, height) / window-> get_dpi_scaling_factor ()). to_i32 ( );
61- window->minimized_ = window->logical_size_ .area () == 0 ;
60+ window->physical_size_ = Vec2I ( width, height);
61+ window->minimized_ = window->physical_size_ .area () == 0 ;
6262
63- Logger::info (" Window resized to physical" + Vec2I (width, height ).to_string () + " , logical" +
64- window->logical_size_ .to_string ());
63+ Logger::info (" Window resized to physical" + window-> get_physical_size ( ).to_string () + " , logical" +
64+ window->get_logical_size () .to_string ());
6565 } else {
6666 Logger::error (" glfwGetWindowUserPointer is NULL!" );
6767 }
0 commit comments