diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 4372cb766..6154bb758 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -564,6 +564,10 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window); #endif +#ifdef defined(GLFW_EXPOSE_NATIVE_ANDROID) +GLFWAPI HWND glfwGetAndroidApp(GLFWwindow* window); +#endif + #ifdef __cplusplus } #endif diff --git a/src/android_platform.h b/src/android_platform.h index 14f3baf0e..4d20f9008 100644 --- a/src/android_platform.h +++ b/src/android_platform.h @@ -63,7 +63,7 @@ typedef struct VkAndroidSurfaceCreateInfoKHR { VkStructureType sType; const void* pNext; VkAndroidSurfaceCreateFlagsKHR flags; - ANativeWindow* surface; + ANativeWindow* window; } VkAndroidSurfaceCreateInfoKHR; typedef VkResult (APIENTRY *PFN_vkCreateAndroidSurfaceKHR)(VkInstance,const VkAndroidSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); diff --git a/src/android_window.c b/src/android_window.c index b375c6c99..5697b6700 100644 --- a/src/android_window.c +++ b/src/android_window.c @@ -39,7 +39,7 @@ struct engine engine; void android_main(struct android_app *app) { memset(&engine, 0, sizeof(engine)); app->userData = &engine; - engine.app = app; + engine.app = &app; glfwMain(); @@ -53,7 +53,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - window->android.app = engine.app; + window->android.app = &engine.app; if (ctxconfig->client != GLFW_NO_API) { if (ctxconfig->source == GLFW_EGL_CONTEXT_API) @@ -312,7 +312,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, memset(&sci, 0, sizeof(sci)); sci.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR; - sci.surface = window->android.app->window; + sci.window = &window->android.app->window; err = vkCreateAndroidSurfaceKHR(instance, &sci, allocator, surface); if (err) @@ -325,3 +325,14 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, return err; } +////////////////////////////////////////////////////////////////////////// +////// GLFW native API ////// +////////////////////////////////////////////////////////////////////////// + +GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return window->android.app; +} +