Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.06k stars 511 forks source link

Pass the correct HINSTANCE for window creation #309

Closed HildarTheDorf closed 3 months ago

HildarTheDorf commented 1 year ago

The HINSTANCE for a window is the HINSTANCE of the module (dll or exe) that contains the window procedure for that window.

The previous code returned the HINSTANCE for the .exe, but the window is created by GLFW. We should therefore pass the HINSTANCE for glfw3. Even better, since we have a HWND, we can just ask the HWND for what it thinks it's HINSTANCE should be.

That said, I don't think many drivers care in practice.

ntsh-oni commented 1 year ago

LONG_PTR cannot be assigned to HINSTANCE so a reinterpret_cast is needed: createInfo.hinstance = reinterpret_cast<HINSTANCE>(GetWindowLongPtr(createInfo.hwnd, GWLP_HINSTANCE));

Overv commented 1 year ago

@HildarTheDorf If you make the change suggested by @ZaOniRinku I will merge this PR.