Fix else branch of chooseSwapExtent for HDPI/retina displays#210
Fix else branch of chooseSwapExtent for HDPI/retina displays#210Overv merged 3 commits intoOverv:masterfrom
Conversation
When using an HDPI display, using the window size `{WIDTH, HEIGHT}` to
determine swapchain image size is incorrect. See the following links:
* https://www.glfw.org/docs/latest/window.html#window_size
* https://www.glfw.org/docs/latest/window.html#window_fbsize
* https://www.glfw.org/faq.html#43---why-is-my-output-in-the-lower-left-corner-of-the-window
Instead, the framebuffer size is now used to determine the swapchain
extent. Using the implementation of `chooseSwapExtent` from
`16_swap_chain_recreation.cpp` seemed appropriate. Beyond "Swap chain
recreation" no changes are necessary.
|
The tutorial is now changed accordingly. I've tried to keep the explanation of the problem as short as possible. I don't know if there is a more elegant solution for this problem. When I write "GLFW uses two units when measuring sizes: pixels and screen coordinates [...]", that's a bit of a lie. There are other measurements, but these are the two that count. |
|
Could you elaborate on the changes besides glfwGetFramebufferSize? |
c53a03e to
f0f4207
Compare
|
My bad, I was careless when I pushed that. Sorry! :( I've amended the commit. Now it should only contain changes relevant to swapchain extent. |
|
Apologies for not getting back to this sooner, thanks for the work! 👍 |
|
Not to worry! Thanks for the tutorial! :) |
Fix else branch of chooseSwapExtent for HDPI/retina displays
When using an HDPI display, using the window size
{WIDTH, HEIGHT}to determine swapchain image size is incorrect. See the following links:Short version: The window size in GLFW is specified in screen coordinates, but Vulkan requires the swapchain image extent to be specified in pixel. On HDPI displays, these are not the same thing.
Instead, the framebuffer size is now used to determine the swapchain extent. Using the implementation of
chooseSwapExtentfrom16_swap_chain_recreation.cppseemed appropriate. Beyond "Swap chain recreation" no changes are necessary.I'm a little bit suprised that this hasn't been an issue for anyone. I'm using macOS, and my app doesn't enter the
elsebranch, so I don't experience any problems either (Vulkan automatically suggests doubled width and height). The specification doesn't seem to say whenwidth == UINT32_MAXoccurs.