Fixes for windows.

This commit is contained in:
Relintai 2024-09-14 14:55:17 +02:00
parent febe2396f1
commit 2afdc35935
2 changed files with 42 additions and 8 deletions

View File

@ -5752,6 +5752,30 @@ GLFWAPI int glfwVulkanSupported(void);
*/
GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
/*! @brief Returns the `HWND` of the specified window as a void*, only works on windows
*
* @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
* function.
* @code
* HDC dc = GetDC(glfwGetWin32WindowAsVPTR(window));
* @endcode
* This DC is private and does not need to be released.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI void *glfwGetWin32WindowAsVPTR(GLFWwindow* window);
#if defined(VK_VERSION_1_0)
/*! @brief Returns the address of the specified Vulkan instance function.
@ -17045,6 +17069,18 @@ const char* _glfwGetVulkanResultString(VkResult result)
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI void *glfwGetWin32WindowAsVPTR(GLFWwindow* handle)
{
#if defined(_WIN64) || defined(_WIN32)
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->win32.handle;
#else
return NULL;
#endif
}
GLFWAPI int glfwVulkanSupported(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);

View File

@ -90,13 +90,11 @@
// GLFW
#ifdef _WIN32
#undef APIENTRY
#ifndef GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WIN32
#endif
//#include <GLFW/glfw3native.h> // for glfwGetWin32Window()
#if defined(_WIN64) || defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#ifdef __APPLE__
#ifndef GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_COCOA
@ -627,7 +625,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = (void*)bd->Window;
#ifdef _WIN32
main_viewport->PlatformHandleRaw = glfwGetWin32Window(bd->Window);
main_viewport->PlatformHandleRaw = glfwGetWin32WindowAsVPTR(bd->Window);
#elif defined(__APPLE__)
main_viewport->PlatformHandleRaw = (void*)glfwGetCocoaWindow(bd->Window);
#else