Compare commits

...

4 Commits

Author SHA1 Message Date
kunitoki
ecbbd33919
Merge 09efa97ef5 into d1b87143bc 2025-07-11 09:16:31 +08:00
Camilla Löwy
d1b87143bc Win32: Remove support for original MinGW
The original MinGW distribution appears to no longer be maintained and
should not be used.  Anyone still using MinGW should consider switching
to the MinGW-w64 fork or another actively maintained toolchain.
MinGW-w64 supports 64-bit binaries and provides much newer compilers and
Win32 headers.

Fixes #2540
2025-07-10 17:59:12 +02:00
Lucio Asnaghi
09efa97ef5 Returns the audio_app without a window 2024-12-04 01:48:11 +01:00
Lucio Asnaghi
de06756d4d Restore android support, rebase to 3.5 2024-12-03 17:07:08 +01:00
25 changed files with 1188 additions and 2894 deletions

View File

@ -29,7 +29,7 @@ for:
only: only:
- GENERATOR: MinGW Makefiles - GENERATOR: MinGW Makefiles
build_script: build_script:
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin% - set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin=%
- cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
- cmake --build build - cmake --build build
- -

View File

@ -41,12 +41,6 @@ indent_size = 2
indent_style = tab indent_style = tab
indent_size = unset indent_size = unset
[deps/mingw/*.h]
indent_style = space
indent_size = 4
tab_width = 8
trim_trailing_whitespace = false
[deps/getopt.{c,h}] [deps/getopt.{c,h}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2

View File

@ -24,10 +24,11 @@ if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE)
"GLFW_USE_WAYLAND has been removed; delete the CMake cache and set GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 instead") "GLFW_USE_WAYLAND has been removed; delete the CMake cache and set GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 instead")
endif() endif()
cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF) cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32;NOT ANDROID" OFF)
cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF) cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE;NOT ANDROID" OFF)
cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF) cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE;NOT ANDROID" OFF)
cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" ON "UNIX;NOT APPLE" OFF) cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" ON "UNIX;NOT APPLE;NOT ANDROID" OFF)
cmake_dependent_option(GLFW_BUILD_ANDROID "Build support for Android" ON "ANDROID" OFF)
cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
"WIN32" OFF) "WIN32" OFF)
@ -66,6 +67,9 @@ endif()
if (GLFW_BUILD_X11) if (GLFW_BUILD_X11)
message(STATUS "Including X11 support") message(STATUS "Including X11 support")
endif() endif()
if (GLFW_BUILD_ANDROID)
message(STATUS "Including Android support")
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Apply Microsoft C runtime library option # Apply Microsoft C runtime library option

View File

@ -52,7 +52,7 @@ and window system. It does not need any additional headers for context creation
APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan) APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan)
to enable support for them. to enable support for them.
GLFW supports compilation on Windows with Visual C++ 2013 and later, MinGW and GLFW supports compilation on Windows with Visual C++ (2013 and later) and
MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
and Clang. It will likely compile in other environments as well, but this is and Clang. It will likely compile in other environments as well, but this is
not regularly tested. not regularly tested.
@ -124,6 +124,7 @@ information on what to include when reporting a bug.
- Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
the limit of the mouse button tokens to be reported (#2423) the limit of the mouse button tokens to be reported (#2423)
- Updated minimum CMake version to 3.16 (#2541) - Updated minimum CMake version to 3.16 (#2541)
- Removed support for building with original MinGW (#2540)
- [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Added `QuartzCore` framework as link-time dependency
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: The fractional scaling related objects were not destroyed

View File

@ -1,117 +0,0 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
#define NONAMELESSUNION 1
#endif
#if defined(NONAMELESSSTRUCT) && \
!defined(NONAMELESSUNION)
#define NONAMELESSUNION 1
#endif
#if defined(NONAMELESSUNION) && \
!defined(NONAMELESSSTRUCT)
#define NONAMELESSSTRUCT 1
#endif
#if !defined(__GNU_EXTENSION)
#if defined(__GNUC__) || defined(__GNUG__)
#define __GNU_EXTENSION __extension__
#else
#define __GNU_EXTENSION
#endif
#endif /* __extension__ */
#ifndef __ANONYMOUS_DEFINED
#define __ANONYMOUS_DEFINED
#if defined(__GNUC__) || defined(__GNUG__)
#define _ANONYMOUS_UNION __extension__
#define _ANONYMOUS_STRUCT __extension__
#else
#define _ANONYMOUS_UNION
#define _ANONYMOUS_STRUCT
#endif
#ifndef NONAMELESSUNION
#define _UNION_NAME(x)
#define _STRUCT_NAME(x)
#else /* NONAMELESSUNION */
#define _UNION_NAME(x) x
#define _STRUCT_NAME(x) x
#endif
#endif /* __ANONYMOUS_DEFINED */
#ifndef DUMMYUNIONNAME
# ifdef NONAMELESSUNION
# define DUMMYUNIONNAME u
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
# define DUMMYUNIONNAME2 u2
# define DUMMYUNIONNAME3 u3
# define DUMMYUNIONNAME4 u4
# define DUMMYUNIONNAME5 u5
# define DUMMYUNIONNAME6 u6
# define DUMMYUNIONNAME7 u7
# define DUMMYUNIONNAME8 u8
# define DUMMYUNIONNAME9 u9
# else /* NONAMELESSUNION */
# define DUMMYUNIONNAME
# define DUMMYUNIONNAME1 /* Wine uses this variant */
# define DUMMYUNIONNAME2
# define DUMMYUNIONNAME3
# define DUMMYUNIONNAME4
# define DUMMYUNIONNAME5
# define DUMMYUNIONNAME6
# define DUMMYUNIONNAME7
# define DUMMYUNIONNAME8
# define DUMMYUNIONNAME9
# endif
#endif /* DUMMYUNIONNAME */
#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */
# ifdef NONAMELESSUNION
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
# else
# define DUMMYUNIONNAME1 /* Wine uses this variant */
# endif
#endif /* DUMMYUNIONNAME1 */
#ifndef DUMMYSTRUCTNAME
# ifdef NONAMELESSUNION
# define DUMMYSTRUCTNAME s
# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */
# define DUMMYSTRUCTNAME2 s2
# define DUMMYSTRUCTNAME3 s3
# define DUMMYSTRUCTNAME4 s4
# define DUMMYSTRUCTNAME5 s5
# else
# define DUMMYSTRUCTNAME
# define DUMMYSTRUCTNAME1 /* Wine uses this variant */
# define DUMMYSTRUCTNAME2
# define DUMMYSTRUCTNAME3
# define DUMMYSTRUCTNAME4
# define DUMMYSTRUCTNAME5
# endif
#endif /* DUMMYSTRUCTNAME */
/* These are for compatibility with the Wine source tree */
#ifndef WINELIB_NAME_AW
# ifdef __MINGW_NAME_AW
# define WINELIB_NAME_AW __MINGW_NAME_AW
# else
# ifdef UNICODE
# define WINELIB_NAME_AW(func) func##W
# else
# define WINELIB_NAME_AW(func) func##A
# endif
# endif
#endif /* WINELIB_NAME_AW */
#ifndef DECL_WINELIB_TYPE_AW
# ifdef __MINGW_TYPEDEF_AW
# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW
# else
# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
# endif
#endif /* DECL_WINELIB_TYPE_AW */

2467
deps/mingw/dinput.h vendored

File diff suppressed because it is too large Load Diff

239
deps/mingw/xinput.h vendored
View File

@ -1,239 +0,0 @@
/*
* The Wine project - Xinput Joystick Library
* Copyright 2008 Andrew Fenn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_XINPUT_H
#define __WINE_XINPUT_H
#include <windef.h>
/*
* Bitmasks for the joysticks buttons, determines what has
* been pressed on the joystick, these need to be mapped
* to whatever device you're using instead of an xbox 360
* joystick
*/
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
#define XINPUT_GAMEPAD_START 0x0010
#define XINPUT_GAMEPAD_BACK 0x0020
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
#define XINPUT_GAMEPAD_A 0x1000
#define XINPUT_GAMEPAD_B 0x2000
#define XINPUT_GAMEPAD_X 0x4000
#define XINPUT_GAMEPAD_Y 0x8000
/*
* Defines the flags used to determine if the user is pushing
* down on a button, not holding a button, etc
*/
#define XINPUT_KEYSTROKE_KEYDOWN 0x0001
#define XINPUT_KEYSTROKE_KEYUP 0x0002
#define XINPUT_KEYSTROKE_REPEAT 0x0004
/*
* Defines the codes which are returned by XInputGetKeystroke
*/
#define VK_PAD_A 0x5800
#define VK_PAD_B 0x5801
#define VK_PAD_X 0x5802
#define VK_PAD_Y 0x5803
#define VK_PAD_RSHOULDER 0x5804
#define VK_PAD_LSHOULDER 0x5805
#define VK_PAD_LTRIGGER 0x5806
#define VK_PAD_RTRIGGER 0x5807
#define VK_PAD_DPAD_UP 0x5810
#define VK_PAD_DPAD_DOWN 0x5811
#define VK_PAD_DPAD_LEFT 0x5812
#define VK_PAD_DPAD_RIGHT 0x5813
#define VK_PAD_START 0x5814
#define VK_PAD_BACK 0x5815
#define VK_PAD_LTHUMB_PRESS 0x5816
#define VK_PAD_RTHUMB_PRESS 0x5817
#define VK_PAD_LTHUMB_UP 0x5820
#define VK_PAD_LTHUMB_DOWN 0x5821
#define VK_PAD_LTHUMB_RIGHT 0x5822
#define VK_PAD_LTHUMB_LEFT 0x5823
#define VK_PAD_LTHUMB_UPLEFT 0x5824
#define VK_PAD_LTHUMB_UPRIGHT 0x5825
#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
#define VK_PAD_RTHUMB_UP 0x5830
#define VK_PAD_RTHUMB_DOWN 0x5831
#define VK_PAD_RTHUMB_RIGHT 0x5832
#define VK_PAD_RTHUMB_LEFT 0x5833
#define VK_PAD_RTHUMB_UPLEFT 0x5834
#define VK_PAD_RTHUMB_UPRIGHT 0x5835
#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
#define VK_PAD_RTHUMB_DOWNLEFT 0x5837
/*
* Deadzones are for analogue joystick controls on the joypad
* which determine when input should be assumed to be in the
* middle of the pad. This is a threshold to stop a joypad
* controlling the game when the player isn't touching the
* controls.
*/
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
/*
* Defines what type of abilities the type of joystick has
* DEVTYPE_GAMEPAD is available for all joysticks, however
* there may be more specific identifiers for other joysticks
* which are being used.
*/
#define XINPUT_DEVTYPE_GAMEPAD 0x01
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
#define XINPUT_DEVSUBTYPE_WHEEL 0x02
#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
#define XINPUT_DEVSUBTYPE_GUITAR 0x06
#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
/*
* These are used with the XInputGetCapabilities function to
* determine the abilities to the joystick which has been
* plugged in.
*/
#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
#define XINPUT_FLAG_GAMEPAD 0x00000001
/*
* Defines the status of the battery if one is used in the
* attached joystick. The first two define if the joystick
* supports a battery. Disconnected means that the joystick
* isn't connected. Wired shows that the joystick is a wired
* joystick.
*/
#define BATTERY_DEVTYPE_GAMEPAD 0x00
#define BATTERY_DEVTYPE_HEADSET 0x01
#define BATTERY_TYPE_DISCONNECTED 0x00
#define BATTERY_TYPE_WIRED 0x01
#define BATTERY_TYPE_ALKALINE 0x02
#define BATTERY_TYPE_NIMH 0x03
#define BATTERY_TYPE_UNKNOWN 0xFF
#define BATTERY_LEVEL_EMPTY 0x00
#define BATTERY_LEVEL_LOW 0x01
#define BATTERY_LEVEL_MEDIUM 0x02
#define BATTERY_LEVEL_FULL 0x03
/*
* How many joysticks can be used with this library. Games that
* use the xinput library will not go over this number.
*/
#define XUSER_MAX_COUNT 4
#define XUSER_INDEX_ANY 0x000000FF
/*
* Defines the structure of an xbox 360 joystick.
*/
typedef struct _XINPUT_GAMEPAD {
WORD wButtons;
BYTE bLeftTrigger;
BYTE bRightTrigger;
SHORT sThumbLX;
SHORT sThumbLY;
SHORT sThumbRX;
SHORT sThumbRY;
} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
typedef struct _XINPUT_STATE {
DWORD dwPacketNumber;
XINPUT_GAMEPAD Gamepad;
} XINPUT_STATE, *PXINPUT_STATE;
/*
* Defines the structure of how much vibration is set on both the
* right and left motors in a joystick. If you're not using a 360
* joystick you will have to map these to your device.
*/
typedef struct _XINPUT_VIBRATION {
WORD wLeftMotorSpeed;
WORD wRightMotorSpeed;
} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
/*
* Defines the structure for what kind of abilities the joystick has
* such abilities are things such as if the joystick has the ability
* to send and receive audio, if the joystick is in fact a driving
* wheel or perhaps if the joystick is some kind of dance pad or
* guitar.
*/
typedef struct _XINPUT_CAPABILITIES {
BYTE Type;
BYTE SubType;
WORD Flags;
XINPUT_GAMEPAD Gamepad;
XINPUT_VIBRATION Vibration;
} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
/*
* Defines the structure for a joystick input event which is
* retrieved using the function XInputGetKeystroke
*/
typedef struct _XINPUT_KEYSTROKE {
WORD VirtualKey;
WCHAR Unicode;
WORD Flags;
BYTE UserIndex;
BYTE HidCode;
} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
typedef struct _XINPUT_BATTERY_INFORMATION
{
BYTE BatteryType;
BYTE BatteryLevel;
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
#ifdef __cplusplus
extern "C" {
#endif
void WINAPI XInputEnable(WINBOOL);
DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
#ifdef __cplusplus
}
#endif
#endif /* __WINE_XINPUT_H */

View File

@ -36,9 +36,9 @@ specific to GLFW. It may be a useful companion to this one.
### Installing dependencies {#compile_deps} ### Installing dependencies {#compile_deps}
The C/C++ development environments in Visual Studio, Xcode and MinGW come with The C/C++ development environments in Visual Studio, Xcode and MinGW-w64 come
all necessary dependencies for compiling GLFW, but on Unix-like systems like with all necessary dependencies for compiling GLFW, but on Unix-like systems
Linux and FreeBSD you will need a few extra packages. like Linux and FreeBSD you will need a few extra packages.
#### Dependencies for Wayland and X11 {#compile_deps_wayland} #### Dependencies for Wayland and X11 {#compile_deps_wayland}
@ -180,7 +180,7 @@ cd path/to/build
make make
``` ```
With MinGW, it is `mingw32-make`. With MinGW-w64, it is `mingw32-make`.
```sh ```sh
cd path/to/build cd path/to/build
@ -299,12 +299,12 @@ library. This option is only available when compiling for Linux and other Unix-
systems other than macOS. This is enabled by default. systems other than macOS. This is enabled by default.
## Cross-compilation with CMake and MinGW {#compile_mingw_cross} ## Cross-compilation with CMake and MinGW-w64 {#compile_mingw_cross}
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For Both Cygwin and many Linux distributions have MinGW-w64 packages. For example,
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages for 32- and
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives like Ubuntu
like Ubuntu have the `mingw-w64` package for both. have the `mingw-w64` package for both.
GLFW has CMake toolchain files in the `CMake` subdirectory that set up GLFW has CMake toolchain files in the `CMake` subdirectory that set up
cross-compilation of Windows binaries. To use these files you set the cross-compilation of Windows binaries. To use these files you set the
@ -315,9 +315,9 @@ configuring and generating the build files.
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
``` ```
The exact toolchain file to use depends on the prefix used by the MinGW or The exact toolchain file to use depends on the prefix used by the MinGW-w64
MinGW-w64 binaries on your system. You can usually see this in the /usr binaries on your system. You can usually see this in the /usr directory. For
directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have example, both the Ubuntu and Cygwin MinGW-w64 packages have
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
would be: would be:

View File

@ -621,11 +621,11 @@ The format of the string is as follows:
- The names of the always supported context creation APIs EGL and OSMesa - The names of the always supported context creation APIs EGL and OSMesa
- Any additional compile-time options, APIs and (on Windows) what compiler was used - Any additional compile-time options, APIs and (on Windows) what compiler was used
For example, compiling GLFW 3.5 with MinGW as a DLL for Windows, may result in a version string For example, compiling GLFW 3.5 with MinGW-64 as a DLL for Windows, may result
like this: in a version string like this:
```c ```c
3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL 3.5.0 Win32 WGL Null EGL OSMesa MinGW-w64 DLL
``` ```
Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may

View File

@ -20,6 +20,15 @@ this.
## Removals {#removals} ## Removals {#removals}
### Original MinGW support has been removed {#original_mingw}
Support for the now unmaintained original MinGW distribution has been removed.
This does not apply to the much more capable [MinGW-w64](https://www.mingw-w64.org/),
which remains fully supported. MinGW-w64 can build both 32- and 64-bit binaries, is
actively maintained and available on many platforms.
## New symbols {#new_symbols} ## New symbols {#new_symbols}
### New functions {#new_functions} ### New functions {#new_functions}

View File

@ -1341,7 +1341,8 @@ extern "C" {
#define GLFW_PLATFORM_COCOA 0x00060002 #define GLFW_PLATFORM_COCOA 0x00060002
#define GLFW_PLATFORM_WAYLAND 0x00060003 #define GLFW_PLATFORM_WAYLAND 0x00060003
#define GLFW_PLATFORM_X11 0x00060004 #define GLFW_PLATFORM_X11 0x00060004
#define GLFW_PLATFORM_NULL 0x00060005 #define GLFW_PLATFORM_ANDROID 0x00060005
#define GLFW_PLATFORM_NULL 0x00060006
/*! @} */ /*! @} */
#define GLFW_DONT_CARE -1 #define GLFW_DONT_CARE -1

View File

@ -155,6 +155,10 @@ extern "C" {
#include <GL/osmesa.h> #include <GL/osmesa.h>
#endif #endif
#if defined(GLFW_EXPOSE_NATIVE_ANDROID)
#include <android_native_app_glue.h>
#endif
#endif /*GLFW_NATIVE_INCLUDE_NONE*/ #endif /*GLFW_NATIVE_INCLUDE_NONE*/
@ -655,6 +659,24 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window); GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
#endif #endif
#if defined(GLFW_EXPOSE_NATIVE_ANDROID)
/*! @brief Returns the `struct android_app` of the current application.
*
* @return The `struct android_app` of the current, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.5.
*
* @ingroup native
*/
GLFWAPI struct android_app* glfwGetAndroidApp(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -57,6 +57,14 @@ if (GLFW_BUILD_WAYLAND)
wl_monitor.c wl_window.c) wl_monitor.c wl_window.c)
endif() endif()
if (GLFW_BUILD_ANDROID)
target_compile_definitions(glfw PRIVATE _GLFW_ANDROID)
target_include_directories(glfw PRIVATE "${ANDROID_NDK}/sources/android/native_app_glue")
target_sources(glfw PRIVATE android_platform.h android_joystick.h android_init.c
android_monitor.c android_window.c android_joystick.c
"${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c")
endif()
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux") if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
@ -255,24 +263,6 @@ if (GLFW_BUILD_WIN32)
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE) target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
endif() endif()
# 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
# win32_platform.h. We define them here until a saner solution can be found
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
if (MINGW)
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
endif()
# Workaround for legacy MinGW not providing XInput and DirectInput
if (MINGW)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
check_include_file(xinput.h XINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
endif()
endif()
# Workaround for the MS CRT deprecating parts of the standard library # Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
@ -286,10 +276,6 @@ endif()
if (GLFW_BUILD_SHARED_LIBRARY) if (GLFW_BUILD_SHARED_LIBRARY)
if (WIN32) if (WIN32)
if (MINGW) if (MINGW)
# Remove the dependency on the shared version of libgcc
# NOTE: MinGW-w64 has the correct default but MinGW needs this
target_link_libraries(glfw PRIVATE "-static-libgcc")
# Remove the lib prefix on the DLL (but not the import library) # Remove the lib prefix on the DLL (but not the import library)
set_target_properties(glfw PROPERTIES PREFIX "") set_target_properties(glfw PROPERTIES PREFIX "")

203
src/android_init.c Normal file
View File

@ -0,0 +1,203 @@
//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2024 kunitoki <kunitoki@gmail.com>
// Copyright (c) 2017 Curi0 <curi0minecraft@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include <android_native_app_glue.h>
#include <android/native_window.h>
#include <android/log.h>
#include "internal.h"
struct android_app* _globalAndroidApp = NULL;
extern int main();
void handleAppCmd(struct android_app* app, int32_t cmd)
{
switch (cmd)
{
case APP_CMD_START:
break;
case APP_CMD_RESUME:
//_glfwInputWindowIconify(_glfw.windowListHead, GLFW_FALSE);
break;
case APP_CMD_PAUSE:
//_glfwInputWindowIconify(_glfw.windowListHead, GLFW_TRUE);
break;
case APP_CMD_STOP:
break;
case APP_CMD_DESTROY:
break;
case APP_CMD_INIT_WINDOW:
break;
case APP_CMD_TERM_WINDOW:
//_glfwInputWindowCloseRequest(_glfw.windowListHead);
break;
case APP_CMD_LOST_FOCUS:
//_glfwInputWindowFocus(_glfw.windowListHead, GLFW_FALSE);
break;
case APP_CMD_GAINED_FOCUS:
//_glfwInputWindowFocus(_glfw.windowListHead, GLFW_TRUE);
break;
case APP_CMD_WINDOW_RESIZED:
_glfwInputWindowSize(_glfw.windowListHead, ANativeWindow_getWidth(app->window), ANativeWindow_getHeight(app->window));
break;
case APP_CMD_WINDOW_REDRAW_NEEDED:
_glfwInputWindowDamage(_glfw.windowListHead);
break;
case APP_CMD_CONTENT_RECT_CHANGED:
_glfwInputFramebufferSize(_glfw.windowListHead, ANativeWindow_getWidth(app->window), ANativeWindow_getHeight(app->window));
break;
case APP_CMD_CONFIG_CHANGED:
break;
case APP_CMD_INPUT_CHANGED:
break;
}
}
// Android Entry Point
void android_main(struct android_app* app)
{
app_dummy();
app->onAppCmd = handleAppCmd;
_globalAndroidApp = app;
main();
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwConnectAndroid(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform android =
{
.platformID = GLFW_PLATFORM_ANDROID,
.init = _glfwInitAndroid,
.terminate = _glfwTerminateAndroid,
.getCursorPos = _glfwGetCursorPosAndroid,
.setCursorPos = _glfwSetCursorPosAndroid,
.setCursorMode = _glfwSetCursorModeAndroid,
.setRawMouseMotion = _glfwSetRawMouseMotionAndroid,
.rawMouseMotionSupported = _glfwRawMouseMotionSupportedAndroid,
.createCursor = _glfwCreateCursorAndroid,
.createStandardCursor = _glfwCreateStandardCursorAndroid,
.destroyCursor = _glfwDestroyCursorAndroid,
.setCursor = _glfwSetCursorAndroid,
.getScancodeName = _glfwGetScancodeNameAndroid,
.getKeyScancode = _glfwGetKeyScancodeAndroid,
.setClipboardString = _glfwSetClipboardStringAndroid,
.getClipboardString = _glfwGetClipboardStringAndroid,
.initJoysticks = _glfwInitJoysticksAndroid,
.terminateJoysticks = _glfwTerminateJoysticksAndroid,
.pollJoystick = _glfwPollJoystickAndroid,
.getMappingName = _glfwGetMappingNameAndroid,
.updateGamepadGUID = _glfwUpdateGamepadGUIDAndroid,
.freeMonitor = _glfwFreeMonitorAndroid,
.getMonitorPos = _glfwGetMonitorPosAndroid,
.getMonitorContentScale = _glfwGetMonitorContentScaleAndroid,
.getMonitorWorkarea = _glfwGetMonitorWorkareaAndroid,
.getVideoModes = _glfwGetVideoModesAndroid,
.getVideoMode = _glfwGetVideoModeAndroid,
.getGammaRamp = _glfwGetGammaRampAndroid,
.setGammaRamp = _glfwSetGammaRampAndroid,
.createWindow = _glfwCreateWindowAndroid,
.destroyWindow = _glfwDestroyWindowAndroid,
.setWindowTitle = _glfwSetWindowTitleAndroid,
.setWindowIcon = _glfwSetWindowIconAndroid,
.getWindowPos = _glfwGetWindowPosAndroid,
.setWindowPos = _glfwSetWindowPosAndroid,
.getWindowSize = _glfwGetWindowSizeAndroid,
.setWindowSize = _glfwSetWindowSizeAndroid,
.setWindowSizeLimits = _glfwSetWindowSizeLimitsAndroid,
.setWindowAspectRatio = _glfwSetWindowAspectRatioAndroid,
.getFramebufferSize = _glfwGetFramebufferSizeAndroid,
.getWindowFrameSize = _glfwGetWindowFrameSizeAndroid,
.getWindowContentScale = _glfwGetWindowContentScaleAndroid,
.iconifyWindow = _glfwIconifyWindowAndroid,
.restoreWindow = _glfwRestoreWindowAndroid,
.maximizeWindow = _glfwMaximizeWindowAndroid,
.showWindow = _glfwShowWindowAndroid,
.hideWindow = _glfwHideWindowAndroid,
.requestWindowAttention = _glfwRequestWindowAttentionAndroid,
.focusWindow = _glfwFocusWindowAndroid,
.setWindowMonitor = _glfwSetWindowMonitorAndroid,
.windowFocused = _glfwWindowFocusedAndroid,
.windowIconified = _glfwWindowIconifiedAndroid,
.windowVisible = _glfwWindowVisibleAndroid,
.windowMaximized = _glfwWindowMaximizedAndroid,
.windowHovered = _glfwWindowHoveredAndroid,
.framebufferTransparent = _glfwFramebufferTransparentAndroid,
.getWindowOpacity = _glfwGetWindowOpacityAndroid,
.setWindowResizable = _glfwSetWindowResizableAndroid,
.setWindowDecorated = _glfwSetWindowDecoratedAndroid,
.setWindowFloating = _glfwSetWindowFloatingAndroid,
.setWindowOpacity = _glfwSetWindowOpacityAndroid,
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughAndroid,
.pollEvents = _glfwPollEventsAndroid,
.waitEvents = _glfwWaitEventsAndroid,
.waitEventsTimeout = _glfwWaitEventsTimeoutAndroid,
.postEmptyEvent = _glfwPostEmptyEventAndroid,
.getEGLPlatform = _glfwGetEGLPlatformAndroid,
.getEGLNativeDisplay = _glfwGetEGLNativeDisplayAndroid,
.getEGLNativeWindow = _glfwGetEGLNativeWindowAndroid,
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsAndroid,
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportAndroid,
.createWindowSurface = _glfwCreateWindowSurfaceAndroid
};
*platform = android;
return GLFW_TRUE;
}
int _glfwInitAndroid(void)
{
_glfw.gstate.app = _globalAndroidApp;
_glfw.gstate.source = NULL;
return GLFW_TRUE;
}
void _glfwTerminateAndroid(void)
{
_glfw.gstate.app = NULL;
}

56
src/android_joystick.c Normal file
View File

@ -0,0 +1,56 @@
//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2024 kunitoki <kunitoki@gmail.com>
// Copyright (c) 2017 Curi0 <curi0minecraft@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include "internal.h"
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitJoysticksAndroid(void)
{
return GLFW_FALSE;
}
void _glfwTerminateJoysticksAndroid(void)
{
}
GLFWbool _glfwPollJoystickAndroid(_GLFWjoystick* js, int mode)
{
return GLFW_FALSE;
}
const char* _glfwGetMappingNameAndroid(void)
{
return "Android";
}
void _glfwUpdateGamepadGUIDAndroid(char* guid)
{
}

35
src/android_joystick.h Normal file
View File

@ -0,0 +1,35 @@
//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2024 kunitoki <kunitoki@gmail.com>
// Copyright (c) 2017 Curi0 <curi0minecraft@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#define GLFW_ANDROID_JOYSTICK_STATE
#define GLFW_ANDROID_LIBRARY_JOYSTICK_STATE
GLFWbool _glfwInitJoysticksAndroid(void);
void _glfwTerminateJoysticksAndroid(void);
GLFWbool _glfwPollJoystickAndroid(_GLFWjoystick* js, int mode);
const char* _glfwGetMappingNameAndroid(void);
void _glfwUpdateGamepadGUIDAndroid(char* guid);

82
src/android_monitor.c Normal file
View File

@ -0,0 +1,82 @@
//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2024 kunitoki <kunitoki@gmail.com>
// Copyright (c) 2017 Curi0 <curi0minecraft@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include "internal.h"
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void _glfwPollMonitorsAndroid(void)
{
}
void _glfwSetVideoModeAndroid(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{
}
void _glfwRestoreVideoModeAndroid(_GLFWmonitor* monitor)
{
}
void _glfwFreeMonitorAndroid(_GLFWmonitor* monitor)
{
}
void _glfwGetMonitorPosAndroid(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
}
void _glfwGetMonitorContentScaleAndroid(_GLFWmonitor* monitor,
float* xscale, float* yscale)
{
}
void _glfwGetMonitorWorkareaAndroid(_GLFWmonitor* monitor,
int* xpos, int* ypos,
int* width, int* height)
{
}
GLFWvidmode* _glfwGetVideoModesAndroid(_GLFWmonitor* monitor, int* count)
{
return NULL;
}
GLFWbool _glfwGetVideoModeAndroid(_GLFWmonitor* monitor, GLFWvidmode *mode)
{
return GLFW_FALSE;
}
GLFWbool _glfwGetGammaRampAndroid(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{
return GLFW_FALSE;
}
void _glfwSetGammaRampAndroid(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
}

134
src/android_platform.h Normal file
View File

@ -0,0 +1,134 @@
//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2024 kunitoki <kunitoki@gmail.com>
// Copyright (c) 2017 Curi0 <curi0minecraft@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include <android_native_app_glue.h>
#include <android/native_window.h>
#include <android/log.h>
#define GLFW_ANDROID_WINDOW_STATE struct android_app* android;
#define GLFW_ANDROID_LIBRARY_WINDOW_STATE android_gstate gstate;
#define GLFW_ANDROID_MONITOR_STATE
#define GLFW_ANDROID_CONTEXT_STATE
#define GLFW_ANDROID_CURSOR_STATE
#define GLFW_ANDROID_LIBRARY_CONTEXT_STATE
#define GLFW_ANDROID_JOYSTICK_STATE
#define GLFW_ANDROID_LIBRARY_JOYSTICK_STATE
typedef struct android_gstate
{
struct android_app* app;
struct android_poll_source* source;
} android_gstate;
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
typedef struct VkAndroidSurfaceCreateInfoKHR
{
VkStructureType sType;
const void* pNext;
VkAndroidSurfaceCreateFlagsKHR flags;
ANativeWindow* window;
} VkAndroidSurfaceCreateInfoKHR;
typedef VkResult (APIENTRY *PFN_vkCreateAndroidSurfaceKHR)(VkInstance, const VkAndroidSurfaceCreateInfoKHR*, const VkAllocationCallbacks*, VkSurfaceKHR*);
GLFWbool _glfwConnectAndroid(int platformID, _GLFWplatform* platform);
int _glfwInitAndroid(void);
void _glfwTerminateAndroid(void);
void _glfwFreeMonitorAndroid(_GLFWmonitor* monitor);
void _glfwGetMonitorPosAndroid(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleAndroid(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaAndroid(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesAndroid(_GLFWmonitor* monitor, int* found);
GLFWbool _glfwGetVideoModeAndroid(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampAndroid(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampAndroid(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwPollMonitorsAndroid(void);
GLFWbool _glfwCreateWindowAndroid(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowAndroid(_GLFWwindow* window);
void _glfwSetWindowTitleAndroid(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconAndroid(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowMonitorAndroid(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
void _glfwGetWindowPosAndroid(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosAndroid(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeAndroid(_GLFWwindow* window, int* width, int* height);
void _glfwSetWindowSizeAndroid(_GLFWwindow* window, int width, int height);
void _glfwSetWindowSizeLimitsAndroid(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
void _glfwSetWindowAspectRatioAndroid(_GLFWwindow* window, int n, int d);
void _glfwGetFramebufferSizeAndroid(_GLFWwindow* window, int* width, int* height);
void _glfwGetWindowFrameSizeAndroid(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
void _glfwGetWindowContentScaleAndroid(_GLFWwindow* window, float* xscale, float* yscale);
void _glfwIconifyWindowAndroid(_GLFWwindow* window);
void _glfwRestoreWindowAndroid(_GLFWwindow* window);
void _glfwMaximizeWindowAndroid(_GLFWwindow* window);
GLFWbool _glfwWindowMaximizedAndroid(_GLFWwindow* window);
GLFWbool _glfwWindowHoveredAndroid(_GLFWwindow* window);
GLFWbool _glfwFramebufferTransparentAndroid(_GLFWwindow* window);
void _glfwSetWindowResizableAndroid(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowDecoratedAndroid(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowFloatingAndroid(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowMousePassthroughAndroid(_GLFWwindow* window, GLFWbool enabled);
float _glfwGetWindowOpacityAndroid(_GLFWwindow* window);
void _glfwSetWindowOpacityAndroid(_GLFWwindow* window, float opacity);
void _glfwSetRawMouseMotionAndroid(_GLFWwindow *window, GLFWbool enabled);
GLFWbool _glfwRawMouseMotionSupportedAndroid(void);
void _glfwShowWindowAndroid(_GLFWwindow* window);
void _glfwRequestWindowAttentionAndroid(_GLFWwindow* window);
void _glfwHideWindowAndroid(_GLFWwindow* window);
void _glfwFocusWindowAndroid(_GLFWwindow* window);
GLFWbool _glfwWindowFocusedAndroid(_GLFWwindow* window);
GLFWbool _glfwWindowIconifiedAndroid(_GLFWwindow* window);
GLFWbool _glfwWindowVisibleAndroid(_GLFWwindow* window);
void _glfwPollEventsAndroid(void);
void _glfwWaitEventsAndroid(void);
void _glfwWaitEventsTimeoutAndroid(double timeout);
void _glfwPostEmptyEventAndroid(void);
void _glfwGetCursorPosAndroid(_GLFWwindow* window, double* xpos, double* ypos);
void _glfwSetCursorPosAndroid(_GLFWwindow* window, double x, double y);
void _glfwSetCursorModeAndroid(_GLFWwindow* window, int mode);
GLFWbool _glfwCreateCursorAndroid(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
GLFWbool _glfwCreateStandardCursorAndroid(_GLFWcursor* cursor, int shape);
void _glfwDestroyCursorAndroid(_GLFWcursor* cursor);
void _glfwSetCursorAndroid(_GLFWwindow* window, _GLFWcursor* cursor);
void _glfwSetClipboardStringAndroid(const char* string);
const char* _glfwGetClipboardStringAndroid(void);
const char* _glfwGetScancodeNameAndroid(int scancode);
int _glfwGetKeyScancodeAndroid(int key);
EGLenum _glfwGetEGLPlatformAndroid(EGLint** attribs);
EGLNativeDisplayType _glfwGetEGLNativeDisplayAndroid(void);
EGLNativeWindowType _glfwGetEGLNativeWindowAndroid(_GLFWwindow* window);
void _glfwGetRequiredInstanceExtensionsAndroid(char** extensions);
GLFWbool _glfwGetPhysicalDevicePresentationSupportAndroid(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
VkResult _glfwCreateWindowSurfaceAndroid(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
GLFWAPI struct android_app* glfwGetAndroidApp(void);

562
src/android_window.c Normal file
View File

@ -0,0 +1,562 @@
//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2024 kunitoki <kunitoki@gmail.com>
// Copyright (c) 2017 Curi0 <curi0minecraft@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include "internal.h"
#include <jni.h>
#include <android/log.h>
#include <android/native_activity.h>
#include <android/configuration.h>
#include <android/window.h>
#include <android/input.h>
#include <string.h>
static float lastCursorPosX = 0.0f;
static float lastCursorPosY = 0.0f;
static void moveNativeWindowToBackground(ANativeActivity* nativeActivity)
{
JNIEnv* env = NULL;
(*nativeActivity->vm)->AttachCurrentThread(nativeActivity->vm, &env, NULL);
jmethodID moveTaskToBackMethod = (*env)->GetMethodID(env, nativeActivity->clazz, "moveTaskToBack", "(Z)Z");
if (moveTaskToBackMethod == NULL)
return;
(*env)->CallBooleanMethod(env, nativeActivity->clazz, moveTaskToBackMethod, JNI_TRUE);
}
static int32_t handleInput(struct android_app* app, AInputEvent* event)
{
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
{
size_t pointerCount = AMotionEvent_getPointerCount(event);
for (size_t i = 0; i < pointerCount; ++i)
{
lastCursorPosX = AMotionEvent_getX(event, i);
lastCursorPosY = AMotionEvent_getY(event, i);
int32_t action = AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK;
// Map Android touch events to GLFW touch events
switch (action)
{
case AMOTION_EVENT_ACTION_DOWN:
case AMOTION_EVENT_ACTION_POINTER_DOWN:
_glfwInputMouseClick(_glfw.windowListHead, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, 0);
break;
case AMOTION_EVENT_ACTION_UP:
case AMOTION_EVENT_ACTION_POINTER_UP:
_glfwInputMouseClick(_glfw.windowListHead, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, 0);
break;
case AMOTION_EVENT_ACTION_MOVE:
_glfwInputCursorPos(_glfw.windowListHead, lastCursorPosX, lastCursorPosY);
break;
case AMOTION_EVENT_ACTION_CANCEL:
// Handle cancel if necessary
break;
}
}
return 1;
}
else if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
{
_glfwInputKey(_glfw.windowListHead, 0 , AKeyEvent_getKeyCode(event), GLFW_PRESS, 0);
return 1;
}
return 0;
}
static void handleEvents(int timeout)
{
ALooper_pollOnce(timeout, NULL, NULL, (void**)&_glfw.gstate.source);
if (_glfw.gstate.source != NULL)
_glfw.gstate.source->process(_glfw.gstate.app, _glfw.gstate.source);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwCreateWindowAndroid(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
// wait for window to become ready
while (_glfw.gstate.app->window == NULL)
handleEvents(-1);
// hmmm maybe should be ANative_Window only?
window->android = _glfw.gstate.app;
window->android->onInputEvent = handleInput;
if (ctxconfig->client != GLFW_NO_API)
{
if ((ctxconfig->source == GLFW_NATIVE_CONTEXT_API) |
(ctxconfig->source == GLFW_EGL_CONTEXT_API))
{
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{
if (!_glfwInitOSMesa())
return GLFW_FALSE;
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
}
return GLFW_TRUE;
}
void _glfwDestroyWindowAndroid(_GLFWwindow* window)
{
if (window->context.destroy)
window->context.destroy(window);
ANativeActivity_finish(window->android->activity);
}
void _glfwSetWindowTitleAndroid(_GLFWwindow* window, const char* title)
{
}
void _glfwSetWindowIconAndroid(_GLFWwindow* window, int count,
const GLFWimage* images)
{
}
void _glfwSetWindowMonitorAndroid(_GLFWwindow* window,
_GLFWmonitor* monitor,
int xpos, int ypos,
int width, int height,
int refreshRate)
{
}
void _glfwGetWindowPosAndroid(_GLFWwindow* window, int* xpos, int* ypos)
{
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 0;
}
void _glfwSetWindowPosAndroid(_GLFWwindow* window, int xpos, int ypos)
{
}
void _glfwGetWindowSizeAndroid(_GLFWwindow* window, int* width, int* height)
{
if (width)
{
*width = (window->android->window != NULL)
? ANativeWindow_getWidth(window->android->window)
: 0;
}
if (height)
{
*height = (window->android->window != NULL)
? ANativeWindow_getHeight(window->android->window)
: 0;
}
}
void _glfwSetWindowSizeAndroid(_GLFWwindow* window, int width, int height)
{
}
void _glfwSetWindowSizeLimitsAndroid(_GLFWwindow* window,
int minwidth, int minheight,
int maxwidth, int maxheight)
{
}
void _glfwSetWindowAspectRatioAndroid(_GLFWwindow* window, int n, int d)
{
}
void _glfwGetFramebufferSizeAndroid(_GLFWwindow* window, int* width, int* height)
{
// the underlying buffer geometry is currently being initialized from the window width and height...
// so high resolution displays are currently not supported...so it is safe to just call _glfwGetWindowSizeAndroid() for now
_glfwGetWindowSizeAndroid(window, width, height);
}
void _glfwGetWindowFrameSizeAndroid(_GLFWwindow* window,
int* left, int* top,
int* right, int* bottom)
{
if (left)
*left = window->android->contentRect.left;
if (top)
*top = window->android->contentRect.top;
if (right)
{
int windowWidth = (window->android->window != NULL)
? ANativeWindow_getWidth(window->android->window)
: 0;
int rightFrame = windowWidth - window->android->contentRect.right;
if (rightFrame < 0) rightFrame = 0;
*right = rightFrame;
}
if (bottom)
{
int windowHeight = (window->android->window != NULL)
? ANativeWindow_getHeight(window->android->window)
: 0;
int bottomFrame = windowHeight - window->android->contentRect.bottom;
if (bottomFrame < 0) bottomFrame = 0;
*bottom = bottomFrame;
}
}
void _glfwGetWindowContentScaleAndroid(_GLFWwindow* window, float* xscale, float* yscale)
{
if (xscale)
{
int32_t widthDensity = AConfiguration_getScreenWidthDp(window->android->config);
if (widthDensity == ACONFIGURATION_SCREEN_WIDTH_DP_ANY)
{
*xscale = 1.0f;
}
else
{
int32_t widthPixels = ANativeWindow_getWidth(window->android->window);
*xscale = (float)widthPixels / (float)widthDensity;
}
}
if (yscale)
{
int32_t heightDensity = AConfiguration_getScreenHeightDp(window->android->config);
if (heightDensity == ACONFIGURATION_SCREEN_HEIGHT_DP_ANY)
{
*yscale = 1.0f;
}
else
{
int32_t heightPixels = ANativeWindow_getHeight(window->android->window);
*yscale = (float)heightPixels / (float)heightDensity;
}
}
}
void _glfwIconifyWindowAndroid(_GLFWwindow* window)
{
moveNativeWindowToBackground(window->android->activity);
}
void _glfwRestoreWindowAndroid(_GLFWwindow* window)
{
}
void _glfwMaximizeWindowAndroid(_GLFWwindow* window)
{
}
GLFWbool _glfwWindowMaximizedAndroid(_GLFWwindow* window)
{
return GLFW_TRUE;
}
GLFWbool _glfwWindowHoveredAndroid(_GLFWwindow* window)
{
return GLFW_FALSE;
}
GLFWbool _glfwFramebufferTransparentAndroid(_GLFWwindow* window)
{
return GLFW_FALSE;
}
void _glfwSetWindowResizableAndroid(_GLFWwindow* window, GLFWbool enabled)
{
}
void _glfwSetWindowDecoratedAndroid(_GLFWwindow* window, GLFWbool enabled)
{
}
void _glfwSetWindowFloatingAndroid(_GLFWwindow* window, GLFWbool enabled)
{
}
void _glfwSetWindowMousePassthroughAndroid(_GLFWwindow* window, GLFWbool enabled)
{
}
float _glfwGetWindowOpacityAndroid(_GLFWwindow* window)
{
return 1.0f;
}
void _glfwSetWindowOpacityAndroid(_GLFWwindow* window, float opacity)
{
}
void _glfwSetRawMouseMotionAndroid(_GLFWwindow *window, GLFWbool enabled)
{
}
GLFWbool _glfwRawMouseMotionSupportedAndroid(void)
{
return GLFW_FALSE;
}
void _glfwShowWindowAndroid(_GLFWwindow* window)
{
}
void _glfwRequestWindowAttentionAndroid(_GLFWwindow* window)
{
}
void _glfwHideWindowAndroid(_GLFWwindow* window)
{
}
void _glfwFocusWindowAndroid(_GLFWwindow* window)
{
}
GLFWbool _glfwWindowFocusedAndroid(_GLFWwindow* window)
{
return GLFW_FALSE;
}
GLFWbool _glfwWindowIconifiedAndroid(_GLFWwindow* window)
{
return GLFW_FALSE;
}
GLFWbool _glfwWindowVisibleAndroid(_GLFWwindow* window)
{
return GLFW_FALSE;
}
void _glfwPollEventsAndroid(void)
{
handleEvents(0);
}
void _glfwWaitEventsAndroid(void)
{
handleEvents(-1);
}
void _glfwWaitEventsTimeoutAndroid(double timeout)
{
handleEvents(timeout * 1e3);
}
void _glfwPostEmptyEventAndroid(void)
{
}
void _glfwGetCursorPosAndroid(_GLFWwindow* window, double* xpos, double* ypos)
{
if (xpos)
*xpos = (double)lastCursorPosX;
if (ypos)
*ypos = (double)lastCursorPosY;
}
void _glfwSetCursorPosAndroid(_GLFWwindow* window, double x, double y)
{
}
void _glfwSetCursorModeAndroid(_GLFWwindow* window, int mode)
{
}
GLFWbool _glfwCreateCursorAndroid(_GLFWcursor* cursor,
const GLFWimage* image,
int xhot, int yhot)
{
return GLFW_TRUE;
}
GLFWbool _glfwCreateStandardCursorAndroid(_GLFWcursor* cursor, int shape)
{
return GLFW_TRUE;
}
void _glfwDestroyCursorAndroid(_GLFWcursor* cursor)
{
}
void _glfwSetCursorAndroid(_GLFWwindow* window, _GLFWcursor* cursor)
{
}
void _glfwSetClipboardStringAndroid(const char* string)
{
}
const char* _glfwGetClipboardStringAndroid(void)
{
return NULL;
}
const char* _glfwGetScancodeNameAndroid(int scancode)
{
return "";
}
int _glfwGetKeyScancodeAndroid(int key)
{
return -1;
}
EGLenum _glfwGetEGLPlatformAndroid(EGLint** attribs)
{
if (_glfw.egl.ANGLE_platform_angle)
{
int type = 0;
if (_glfw.egl.ANGLE_platform_angle_opengl)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGLES)
type = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
}
if (_glfw.egl.ANGLE_platform_angle_vulkan)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
}
if (type)
{
*attribs = _glfw_calloc(3, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_NONE;
return EGL_PLATFORM_ANGLE_ANGLE;
}
}
return 0;
}
EGLNativeDisplayType _glfwGetEGLNativeDisplayAndroid(void)
{
return EGL_DEFAULT_DISPLAY;
}
EGLNativeWindowType _glfwGetEGLNativeWindowAndroid(_GLFWwindow* window)
{
return ((EGLNativeWindowType) window->android->window);
}
void _glfwGetRequiredInstanceExtensionsAndroid(char** extensions)
{
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_android_surface)
return;
extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_android_surface";
}
GLFWbool _glfwGetPhysicalDevicePresentationSupportAndroid(VkInstance instance,
VkPhysicalDevice device,
uint32_t queuefamily)
{
return GLFW_TRUE;
}
VkResult _glfwCreateWindowSurfaceAndroid(VkInstance instance,
_GLFWwindow* window,
const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface)
{
VkResult err;
VkAndroidSurfaceCreateInfoKHR sci;
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
vkCreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR");
if (!vkCreateAndroidSurfaceKHR)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Android: Vulkan instance missing VK_KHR_android_surface extension");
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
memset(&sci, 0, sizeof(sci));
sci.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
sci.window = window->android->window;
err = vkCreateAndroidSurfaceKHR(instance, &sci, allocator, surface);
if (err)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Android: Failed to create Vulkan surface: %s",
_glfwGetVulkanResultString(err));
}
return err;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI struct android_app* glfwGetAndroidApp(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfw.gstate.app;
}

View File

@ -374,6 +374,8 @@ GLFWbool _glfwInitEGL(void)
"EGL.dll", "EGL.dll",
#elif defined(_GLFW_COCOA) #elif defined(_GLFW_COCOA)
"libEGL.dylib", "libEGL.dylib",
#elif defined(_GLFW_ANDROID)
"libEGL.so",
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
"libEGL-1.so", "libEGL-1.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__NetBSD__)
@ -773,6 +775,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
"libGLES_CM.dll", "libGLES_CM.dll",
#elif defined(_GLFW_COCOA) #elif defined(_GLFW_COCOA)
"libGLESv1_CM.dylib", "libGLESv1_CM.dylib",
#elif defined(_GLFW_ANDROID)
"libGLESv1_CM.so",
"libGLES_CM.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__NetBSD__)
"libGLESv1_CM.so", "libGLESv1_CM.so",
#else #else
@ -790,6 +795,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
"libGLESv2.dll", "libGLESv2.dll",
#elif defined(_GLFW_COCOA) #elif defined(_GLFW_COCOA)
"libGLESv2.dylib", "libGLESv2.dylib",
#elif defined(_GLFW_ANDROID)
"libGLESv2.so",
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
"libGLESv2-2.so", "libGLESv2-2.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__NetBSD__)

View File

@ -285,6 +285,7 @@ typedef enum VkStructureType
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000,
VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000,
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType; } VkStructureType;
@ -872,6 +873,7 @@ struct _GLFWlibrary
GLFWbool KHR_xlib_surface; GLFWbool KHR_xlib_surface;
GLFWbool KHR_xcb_surface; GLFWbool KHR_xcb_surface;
GLFWbool KHR_wayland_surface; GLFWbool KHR_wayland_surface;
GLFWbool KHR_android_surface;
GLFWbool EXT_headless_surface; GLFWbool EXT_headless_surface;
} vk; } vk;

View File

@ -56,6 +56,9 @@ static const struct
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
{ GLFW_PLATFORM_X11, _glfwConnectX11 }, { GLFW_PLATFORM_X11, _glfwConnectX11 },
#endif #endif
#if defined(_GLFW_ANDROID)
{ GLFW_PLATFORM_ANDROID, _glfwConnectAndroid },
#endif
}; };
GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
@ -68,6 +71,7 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
desiredID != GLFW_PLATFORM_COCOA && desiredID != GLFW_PLATFORM_COCOA &&
desiredID != GLFW_PLATFORM_WAYLAND && desiredID != GLFW_PLATFORM_WAYLAND &&
desiredID != GLFW_PLATFORM_X11 && desiredID != GLFW_PLATFORM_X11 &&
desiredID != GLFW_PLATFORM_ANDROID &&
desiredID != GLFW_PLATFORM_NULL) desiredID != GLFW_PLATFORM_NULL)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", desiredID); _glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", desiredID);
@ -147,6 +151,7 @@ GLFWAPI int glfwPlatformSupported(int platformID)
platformID != GLFW_PLATFORM_COCOA && platformID != GLFW_PLATFORM_COCOA &&
platformID != GLFW_PLATFORM_WAYLAND && platformID != GLFW_PLATFORM_WAYLAND &&
platformID != GLFW_PLATFORM_X11 && platformID != GLFW_PLATFORM_X11 &&
platformID != GLFW_PLATFORM_ANDROID &&
platformID != GLFW_PLATFORM_NULL) platformID != GLFW_PLATFORM_NULL)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", platformID); _glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", platformID);
@ -181,14 +186,15 @@ GLFWAPI const char* glfwGetVersionString(void)
#endif #endif
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
" X11 GLX" " X11 GLX"
#endif
#if defined(_GLFW_ANDROID)
" Android"
#endif #endif
" Null" " Null"
" EGL" " EGL"
" OSMesa" " OSMesa"
#if defined(__MINGW64_VERSION_MAJOR) #if defined(__MINGW64_VERSION_MAJOR)
" MinGW-w64" " MinGW-w64"
#elif defined(__MINGW32__)
" MinGW"
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
" VisualC" " VisualC"
#endif #endif
@ -209,4 +215,3 @@ GLFWAPI const char* glfwGetVersionString(void)
#endif #endif
; ;
} }

View File

@ -90,6 +90,18 @@
#define GLFW_GLX_LIBRARY_CONTEXT_STATE #define GLFW_GLX_LIBRARY_CONTEXT_STATE
#endif #endif
#if defined(_GLFW_ANDROID)
#include "android_platform.h"
#define GLFW_EXPOSE_NATIVE_EGL
#else
#define GLFW_ANDROID_WINDOW_STATE
#define GLFW_ANDROID_MONITOR_STATE
#define GLFW_ANDROID_CURSOR_STATE
#define GLFW_ANDROID_LIBRARY_WINDOW_STATE
#define GLFW_ANDROID_CONTEXT_STATE
#define GLFW_ANDROID_LIBRARY_CONTEXT_STATE
#endif
#include "null_joystick.h" #include "null_joystick.h"
#if defined(_GLFW_WIN32) #if defined(_GLFW_WIN32)
@ -106,6 +118,13 @@
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE #define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
#endif #endif
#if defined(_GLFW_ANDROID)
#include "android_joystick.h"
#else
#define GLFW_ANDROID_JOYSTICK_STATE
#define GLFW_ANDROID_LIBRARY_JOYSTICK_STATE
#endif
#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__) #if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__)
#define GLFW_BUILD_LINUX_JOYSTICK #define GLFW_BUILD_LINUX_JOYSTICK
#endif #endif
@ -122,6 +141,7 @@
GLFW_COCOA_WINDOW_STATE \ GLFW_COCOA_WINDOW_STATE \
GLFW_WAYLAND_WINDOW_STATE \ GLFW_WAYLAND_WINDOW_STATE \
GLFW_X11_WINDOW_STATE \ GLFW_X11_WINDOW_STATE \
GLFW_ANDROID_WINDOW_STATE \
GLFW_NULL_WINDOW_STATE \ GLFW_NULL_WINDOW_STATE \
#define GLFW_PLATFORM_MONITOR_STATE \ #define GLFW_PLATFORM_MONITOR_STATE \
@ -129,6 +149,7 @@
GLFW_COCOA_MONITOR_STATE \ GLFW_COCOA_MONITOR_STATE \
GLFW_WAYLAND_MONITOR_STATE \ GLFW_WAYLAND_MONITOR_STATE \
GLFW_X11_MONITOR_STATE \ GLFW_X11_MONITOR_STATE \
GLFW_ANDROID_MONITOR_STATE \
GLFW_NULL_MONITOR_STATE \ GLFW_NULL_MONITOR_STATE \
#define GLFW_PLATFORM_CURSOR_STATE \ #define GLFW_PLATFORM_CURSOR_STATE \
@ -136,11 +157,13 @@
GLFW_COCOA_CURSOR_STATE \ GLFW_COCOA_CURSOR_STATE \
GLFW_WAYLAND_CURSOR_STATE \ GLFW_WAYLAND_CURSOR_STATE \
GLFW_X11_CURSOR_STATE \ GLFW_X11_CURSOR_STATE \
GLFW_ANDROID_CURSOR_STATE \
GLFW_NULL_CURSOR_STATE \ GLFW_NULL_CURSOR_STATE \
#define GLFW_PLATFORM_JOYSTICK_STATE \ #define GLFW_PLATFORM_JOYSTICK_STATE \
GLFW_WIN32_JOYSTICK_STATE \ GLFW_WIN32_JOYSTICK_STATE \
GLFW_COCOA_JOYSTICK_STATE \ GLFW_COCOA_JOYSTICK_STATE \
GLFW_ANDROID_JOYSTICK_STATE \
GLFW_LINUX_JOYSTICK_STATE GLFW_LINUX_JOYSTICK_STATE
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \ #define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
@ -148,12 +171,14 @@
GLFW_COCOA_LIBRARY_WINDOW_STATE \ GLFW_COCOA_LIBRARY_WINDOW_STATE \
GLFW_WAYLAND_LIBRARY_WINDOW_STATE \ GLFW_WAYLAND_LIBRARY_WINDOW_STATE \
GLFW_X11_LIBRARY_WINDOW_STATE \ GLFW_X11_LIBRARY_WINDOW_STATE \
GLFW_NULL_LIBRARY_WINDOW_STATE \ GLFW_ANDROID_LIBRARY_WINDOW_STATE \
GLFW_NULL_LIBRARY_WINDOW_STATE
#define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ #define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
GLFW_WIN32_LIBRARY_JOYSTICK_STATE \ GLFW_WIN32_LIBRARY_JOYSTICK_STATE \
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \ GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
GLFW_LINUX_LIBRARY_JOYSTICK_STATE GLFW_LINUX_LIBRARY_JOYSTICK_STATE \
GLFW_ANDROID_LIBRARY_JOYSTICK_STATE
#define GLFW_PLATFORM_CONTEXT_STATE \ #define GLFW_PLATFORM_CONTEXT_STATE \
GLFW_WGL_CONTEXT_STATE \ GLFW_WGL_CONTEXT_STATE \

View File

@ -61,6 +61,8 @@ GLFWbool _glfwInitVulkan(int mode)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib");
if (!_glfw.vk.handle) if (!_glfw.vk.handle)
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa();
#elif defined(_GLFW_ANDROID)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
#elif defined(__OpenBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__NetBSD__)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so"); _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
#else #else
@ -142,6 +144,8 @@ GLFWbool _glfwInitVulkan(int mode)
_glfw.vk.KHR_xcb_surface = GLFW_TRUE; _glfw.vk.KHR_xcb_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
_glfw.vk.KHR_wayland_surface = GLFW_TRUE; _glfw.vk.KHR_wayland_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_android_surface") == 0)
_glfw.vk.KHR_android_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_EXT_headless_surface") == 0) else if (strcmp(ep[i].extensionName, "VK_EXT_headless_surface") == 0)
_glfw.vk.EXT_headless_surface = GLFW_TRUE; _glfw.vk.EXT_headless_surface = GLFW_TRUE;
} }

View File

@ -83,24 +83,12 @@
#ifndef WM_COPYGLOBALDATA #ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x0049 #define WM_COPYGLOBALDATA 0x0049
#endif #endif
#ifndef WM_UNICHAR
#define WM_UNICHAR 0x0109
#endif
#ifndef UNICODE_NOCHAR
#define UNICODE_NOCHAR 0xFFFF
#endif
#ifndef WM_DPICHANGED #ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0 #define WM_DPICHANGED 0x02E0
#endif #endif
#ifndef GET_XBUTTON_WPARAM
#define GET_XBUTTON_WPARAM(w) (HIWORD(w))
#endif
#ifndef EDS_ROTATEDMODE #ifndef EDS_ROTATEDMODE
#define EDS_ROTATEDMODE 0x00000004 #define EDS_ROTATEDMODE 0x00000004
#endif #endif
#ifndef DISPLAY_DEVICE_ACTIVE
#define DISPLAY_DEVICE_ACTIVE 0x00000001
#endif
#ifndef _WIN32_WINNT_WINBLUE #ifndef _WIN32_WINNT_WINBLUE
#define _WIN32_WINNT_WINBLUE 0x0603 #define _WIN32_WINNT_WINBLUE 0x0603
#endif #endif
@ -113,9 +101,6 @@
#ifndef USER_DEFAULT_SCREEN_DPI #ifndef USER_DEFAULT_SCREEN_DPI
#define USER_DEFAULT_SCREEN_DPI 96 #define USER_DEFAULT_SCREEN_DPI 96
#endif #endif
#ifndef OCR_HAND
#define OCR_HAND 32649
#endif
#if WINVER < 0x0601 #if WINVER < 0x0601
typedef struct typedef struct