Simplify glfw import on mac.

This commit is contained in:
Relintai 2024-09-14 16:42:27 +02:00
parent 7dc440b01d
commit ba38f48840
2 changed files with 13 additions and 12 deletions

View File

@ -5752,7 +5752,7 @@ 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
/*! @brief Returns the `HWND` of the specified window as a void*, only works on windows, and osx
*
* @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
@ -5774,7 +5774,7 @@ GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
*
* @ingroup native
*/
GLFWAPI void *glfwGetWin32WindowAsVPTR(GLFWwindow* window);
GLFWAPI void *glfwGetNativeWindowHandleAsVPTR(GLFWwindow* window);
#if defined(VK_VERSION_1_0)
@ -17070,12 +17070,16 @@ const char* _glfwGetVulkanResultString(VkResult result)
//////////////////////////////////////////////////////////////////////////
GLFWAPI void *glfwGetWin32WindowAsVPTR(GLFWwindow* handle)
GLFWAPI void *glfwGetNativeWindowHandleAsVPTR(GLFWwindow* handle)
{
#if defined(_WIN64) || defined(_WIN32)
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->win32.handle;
#elif defined(__APPLE__)
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
return window->ns.object;
#else
return NULL;
#endif

View File

@ -95,19 +95,13 @@
#include <windows.h>
#endif
#ifdef __APPLE__
#ifndef GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_COCOA
#endif
//#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
#endif
#include "render_core/3rd_glfw3.h"
#ifndef _WIN32
#include <unistd.h> // for usleep()
#endif
/*
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/html5.h>
@ -117,6 +111,7 @@
#define EMSCRIPTEN_USE_EMBEDDED_GLFW3
#endif
#endif
*/
// We gather version tests as define in order to easily see which features are version-dependent.
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
@ -625,9 +620,11 @@ 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 = glfwGetWin32WindowAsVPTR(bd->Window);
//main_viewport->PlatformHandleRaw = glfwGetWin32Window(bd->Window);
main_viewport->PlatformHandleRaw = glfwGetNativeWindowHandleAsVPTR(bd->Window);
#elif defined(__APPLE__)
main_viewport->PlatformHandleRaw = (void*)glfwGetCocoaWindow(bd->Window);
//main_viewport->PlatformHandleRaw = (void*)glfwGetCocoaWindow(bd->Window);
main_viewport->PlatformHandleRaw = glfwGetNativeWindowHandleAsVPTR(bd->Window);
#else
IM_UNUSED(main_viewport);
#endif