VulkanTutorial icon indicating copy to clipboard operation
VulkanTutorial copied to clipboard

Pass the correct HINSTANCE for window creation

Open HildarTheDorf opened this issue 3 years ago • 2 comments

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.

HildarTheDorf avatar Oct 14 '22 14:10 HildarTheDorf

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

ntsh-oni avatar Oct 14 '22 14:10 ntsh-oni

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

Overv avatar Nov 03 '22 22:11 Overv