Skip to content

Commit 4a87054

Browse files
committed
Fix bad window position initialisation.
Checking if glfwCreateWindow actually set the position to the requested one.
1 parent 89a4e87 commit 4a87054

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/Platform/Window.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ namespace Platform
3838
m_handle = glfwCreateWindow(desired_size_windowed.x, desired_size_windowed.y, Config::Is_Debug ? "Spirit - Debug" : "Spirit", NULL, NULL);
3939
ASSERT(m_handle != nullptr, "[WINDOW] Failed to construct Window");
4040

41-
m_last_size_windowed = size(); // Get the actual size of the window after creation. Per GLFW docs, this may not be the same as the requested size.
42-
const glm::ivec2 desired_position_windowed = {wa_xpos + (wa_width - m_last_size_windowed.x) * 0.5f, wa_ypos + (wa_height - m_last_size_windowed.y) * 0.5f};
41+
// Check the actual size of the window after creation. Per GLFW docs, this may not be the same as the requested size.
42+
if (size() != glm::uvec2(desired_size_windowed))
43+
set_size(desired_size_windowed);
44+
45+
const glm::ivec2 desired_position_windowed =
46+
{
47+
wa_xpos + (wa_width - m_last_size_windowed.x) * 0.5f,
48+
wa_ypos + (wa_height - m_last_size_windowed.y) * 0.5f
49+
};
4350
set_position(desired_position_windowed);
51+
4452
set_VSync(m_VSync);
4553
glfwMakeContextCurrent(m_handle); // Set this window as the context for GL render calls.
4654

0 commit comments

Comments
 (0)