Reputation: 927
I've been unable to find anything about this. Given a window created with SFML (assuming ofcourse were on Windows):
sf::Window window(sf::VideoMode(800, 600), "My window");
Is it possible to get the actual HWND and HInstance of the created window? Some getter? or perhaps a neat hack?
Something like:
window.getHWND()
window.getHInstance()
Would be pretty ideal, but it dosent exist. Any suggestions are appreciated.
Update
This is not a duplicate of this question, because im specifically asking how to retrive the HWND and HInstance of the SFML window. Not how to integrate Vulkan with SFML. So issues of an SFML window already having a swapchain is irrelevant to this question, not to the other one tho. I just included the context in case anyone was wondering. Sorry for the confusion.
Upvotes: 3
Views: 1048
Reputation: 13246
This is practically a duplicate of Using Vulkan with SFML?, but asked as a XY problem.
OpenGL seems to be hard dependency of SFML. I assume SFML immediatelly calls SetPixelFormat
, and creates OpenGL swap chain (i.e. "context") on top of it.
If that is so, that makes it unusable in Vulkan. If it works, that would be only because undefined behavior, or because non-compliant Vulkan Implementation.
It is discussed in two places in the Vulkan Specification.
Firstly Issue 2) in VK_KHR_win32_surface
appendix goes over it thoroughly. In summary it says:
Uses of a window object by multiple graphics APIs results in undefined behavior.
Secondly in vkCreateSwapchainKHR
behavior it says:
If the native window referred to by
surface
is already associated with a non-Vulkan graphics API surface,VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
must be returned.
Upvotes: 0
Reputation: 36477
What you're looking for is sf::Window::getSystemHandle()
, which will return a sf::WindowHandle
, which is platform dependent and on Windows it's basically the HWND
.
To get your HINSTANCE
, either use your own WinMain()
entry point or call GetModuleHandle(NULL);
as long as you're not writing a library.
Upvotes: 3