diff --git a/CMakeLists.txt b/CMakeLists.txt index c4985675d..d876aba4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,6 +333,13 @@ if (_GLFW_COCOA) set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo") endif() +#-------------------------------------------------------------------- +# Use Android APIs for window creation +#-------------------------------------------------------------------- +if (_GLFW_ANDROID) + list(APPEND glfw_INCLUDE_DIRS "${ANDROID_NDK}/sources/android/native_app_glue/") +endif() + #-------------------------------------------------------------------- # Export GLFW library dependencies #-------------------------------------------------------------------- diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 8d1600d91..31c973206 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -197,7 +197,7 @@ extern "C" { #include #endif - #elif !defined(ANDROID) /*__APPLE__*/ + #else /*__APPLE__*/ #include #if defined(GLFW_INCLUDE_GLEXT) @@ -5207,4 +5207,4 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window } #endif -#endif /* _glfw3_h_ */ \ No newline at end of file +#endif /* _glfw3_h_ */ diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index f9ec60eef..f499a53bd 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -123,6 +123,9 @@ extern "C" { #include #endif +#if defined(GLFW_EXPOSE_NATIVE_ANDROID) + #include +#endif /************************************************************************* * Functions diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c58314187..4ed950496 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,8 +100,7 @@ target_include_directories(glfw PUBLIC target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/src" "${GLFW_BINARY_DIR}/src" - ${glfw_INCLUDE_DIRS} - ${ANDROID_NDK}/sources/android/native_app_glue/) + ${glfw_INCLUDE_DIRS}) # HACK: When building on MinGW, WINVER and UNICODE need to be defined before # the inclusion of stddef.h (by glfw3.h), which is itself included before diff --git a/src/android_init.c b/src/android_init.c index 13100a21c..590e21252 100644 --- a/src/android_init.c +++ b/src/android_init.c @@ -82,6 +82,6 @@ void _glfwPlatformTerminate(void) const char* _glfwPlatformGetVersionString(void) { - return _GLFW_VERSION_NUMBER " Android"; + return _GLFW_VERSION_NUMBER " Android EGL"; } diff --git a/src/android_platform.h b/src/android_platform.h index 616cc088e..ea33266f2 100644 --- a/src/android_platform.h +++ b/src/android_platform.h @@ -47,10 +47,10 @@ #define _GLFW_PLATFORM_CONTEXT_STATE #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE +#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY struct android_app *app; - typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; typedef struct VkAndroidSurfaceCreateInfoKHR { diff --git a/src/android_window.c b/src/android_window.c index ab1c36fc4..1faf2308e 100644 --- a/src/android_window.c +++ b/src/android_window.c @@ -339,4 +339,4 @@ GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*)handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return window->android; -} \ No newline at end of file +} diff --git a/src/egl_context.c b/src/egl_context.c index 40aa25f65..742e7f4ac 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -393,11 +393,8 @@ GLFWbool _glfwInitEGL(void) _glfwTerminateEGL(); return GLFW_FALSE; } - #if !defined(ANDROID) - _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY); - #else - _glfw.egl.display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - #endif + + _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY); if (_glfw.egl.display == EGL_NO_DISPLAY) { diff --git a/src/egl_context.h b/src/egl_context.h index fded86445..2c4a3b6a8 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -26,31 +26,31 @@ //======================================================================== #if defined(_GLFW_USE_EGLPLATFORM_H) -#include + #include #elif defined(_GLFW_ANDROID) -#define EGLAPIENTRY -typedef void* EGLNativeDisplayType; -typedef struct ANativeWindow* EGLNativeWindowType; + #define EGLAPIENTRY + typedef void* EGLNativeDisplayType; + typedef struct ANativeWindow* EGLNativeWindowType; #elif defined(_GLFW_WIN32) -#define EGLAPIENTRY __stdcall -typedef HDC EGLNativeDisplayType; -typedef HWND EGLNativeWindowType; + #define EGLAPIENTRY __stdcall + typedef HDC EGLNativeDisplayType; + typedef HWND EGLNativeWindowType; #elif defined(_GLFW_COCOA) -#define EGLAPIENTRY -typedef void* EGLNativeDisplayType; -typedef id EGLNativeWindowType; + #define EGLAPIENTRY + typedef void* EGLNativeDisplayType; + typedef id EGLNativeWindowType; #elif defined(_GLFW_X11) -#define EGLAPIENTRY -typedef Display* EGLNativeDisplayType; -typedef Window EGLNativeWindowType; + #define EGLAPIENTRY + typedef Display* EGLNativeDisplayType; + typedef Window EGLNativeWindowType; #elif defined(_GLFW_WAYLAND) -#define EGLAPIENTRY -typedef struct wl_display* EGLNativeDisplayType; -typedef struct wl_egl_window* EGLNativeWindowType; + #define EGLAPIENTRY + typedef struct wl_display* EGLNativeDisplayType; + typedef struct wl_egl_window* EGLNativeWindowType; #elif defined(_GLFW_MIR) -#define EGLAPIENTRY -typedef MirEGLNativeDisplayType EGLNativeDisplayType; -typedef MirEGLNativeWindowType EGLNativeWindowType; + #define EGLAPIENTRY + typedef MirEGLNativeDisplayType EGLNativeDisplayType; + typedef MirEGLNativeWindowType EGLNativeWindowType; #else #error "No supported EGL platform selected" #endif