347 Commits

Author SHA1 Message Date
Robert Bragg da29177b41 Only build examples with stable toolchain
Although we want to ensure android-activity itself builds with the
same MSRV as Winit there's no need to also check that the examples
build with an older toolchain, and in fact in the case of Egui based
examples they don't support being built with 1.60.0.

In addition to adding an `if: rust_version == "stable"` condition
for building agdk-egui, this also adds CI stages to build agdk-mainloop,
na-mainloop and agdk-eframe to cover at least one example based on
`NativeActivity` and cover the key examples that others are most
likely to be interested in.
2022-09-01 14:14:08 +01:00
Robert Bragg b29162d149 Revert "Support building with 1.57.0 compiler"
This reverts the changes from 66e3293f4d
to support the 1.57.0 compiler (leaving the rustdoc fixes).

Making the changes to support 1.57 felt disappointing to require for the
sake of Winit being able to better support Linux distro packaging. Even
with the changes we still wouldn't really support
1.57 without also upstreaming changes to `cargo ndk`.

The new plan is to bank on Winit bumping its own MSRV to at least
1.58 which seems more than reasonable considering that even 1.59
is already >6months old.

Ref: https://github.com/rust-windowing/winit/pull/2453

This updates ci.yml to now build with 1.60, assuming that the above
PR will be accepted.
2022-09-01 12:37:07 +01:00
Robert Bragg 3a2fa5d1fa CI: build docs and ensure support for 1.57.0 compiler 2022-08-31 23:05:24 +01:00
Robert Bragg 66e3293f4d Support building with 1.57.0 compiler
This is to support the same compiler versions as Winit
2022-08-31 23:04:09 +01:00
Robert Bragg d5ff06ffb2 Add OpenXR + Wgpu example
This tests being able to write an OpenXR application based on
Wgpu (using the Vulkan HAL backend) for the Oculus Quest.
2022-08-31 20:44:14 +01:00
Robert Bragg b7f01a43d9 Build fixes for Winit based examples
The latest branches for Winit (which update the Android backend to
use android-activity) now depend on the android-activity 0.2
release which broke the patching assumption for the Winit examples.
(they were patching based on the git url not crates.io)

It was also noticed that the latest android-activity-0.27 branch
isn't compatible with Egui currently because the (badly named) branch
is based on Winit master and there was recently a breaking API change
adding new window events which breaks Egui.

A note about the badly name branches has been added to the Cargo.toml
files for the Winit examples (they can't currently be fixes since
the -0.27 branch is part of a pull request).

For reference here:
- "android-activity" is based on Winit 0.27 (required for Egui compatibility)
- "android-activity-0.27" is based on Winit master

This patch adds Cargo.lock files for the Winit examples.

Fixes: #22
2022-08-31 20:43:45 +01:00
Robert Bragg f673662316 Add a minimal OpenXR Info example 2022-08-26 17:27:03 +01:00
Robert Bragg 5dab74466c Release 0.2 v0.2.0 2022-08-25 10:34:31 +01:00
Robert Bragg 11c3af686f examples: winit simplifications
* Since we can rely on `Resumed` events for all platforms with Winit 0.27
we can remove the alternative `NewEvents` path for initializing state.
* Removes some unnecessary abstraction for the app state.
* Bumps agdk-egui to egui 0.19 (Winit 0.27)
2022-08-24 21:23:29 +01:00
John Kåre Alsaker 58bc3f6de7 Add eframe example
Co-authored-by: Robert Bragg <robert@sixbynine.org>
2022-08-24 20:35:41 +01:00
Robert Bragg 6ea3f82fb8 agdk-egui: revert back to updated android-activity-0.27 Winit branch 2022-08-14 11:06:27 +01:00
Robert Bragg fb9a9f15c8 agdk-egui: use staging branch for winit, for CI build 2022-08-14 11:02:22 +01:00
Robert Bragg 3e95c428f5 Remove old portability comment for InputAvailable event 2022-08-14 11:02:22 +01:00
Robert Bragg 5d78da7296 Remove FdEvent while it's unused for now
Considering the possibility of using epoll directly or perhaps mio in
the future instead of the ALooper wrapper API then this just removes
the FdEvent and Error enum values from PollEvent as a simplification
in case they could make it harder to keep compatibility in the future.
2022-08-14 11:02:22 +01:00
Robert Bragg b1a63aeee6 Remove NativeWindowRef type
Since ndk 0.7 the `NativeWindow` type implements Clone and Drop
which makes this wrapper type redundant now.
2022-08-14 11:02:22 +01:00
Robert Bragg 206c8e2c84 Make ContentRectChanged event a non_exhaustive struct
Just to keep open the ability to add state to the event in the future
without needing an API break.
2022-08-14 11:02:22 +01:00
Robert Bragg a654f72f62 Expose the application Configuration by reference
This provides an API to access `Configuration` state for the application
without having to make deep copies of the large `Configuration` struct.

This should avoid the need for Winit to create a global static copy of
the Configuration whenever it changes - and instead it can just get
a `ConfigurationRef` which will always reflect the latest config for
the application.

Fixes: #5
2022-08-14 11:02:22 +01:00
Robert Bragg b161b24ce4 Make AndroidApp Send + Sync
In Winit then we ideally want to be able to associate a cloned reference to
the AndroidApp with the `Window` and `MonitorHandle` types (since that's the
most practical way to access the native_window and config state for the
application) but for that `AndroidApp` needs to be Send + Sync
2022-08-14 11:02:22 +01:00
Robert Bragg a735faa753 Add an initial CHANGELOG.md
Based on https://keepachangelog.com/en/1.0.0
2022-08-14 00:48:48 +01:00
Robert Bragg 2a9ed44d93 agdk-cpal: Use cpal git master
I was mistaken recently, thinking that cpal's dev-dependency on ndk-glue
was somehow being inherited by the example. Actually the real issue was
that cpal 0.13.5 has a regular _dependency_ on ndk-glue, which is a much
simpler explanation for why we were seeing a crash.

This updates the example to just use the master branch of cpal, which we'll
need until there is a new release of cpal.
2022-08-14 00:16:21 +01:00
Robert Bragg 3d1b1c5cb9 Supports InputAvailable events with GameActivity
This makes a small change to the C glue code for GameActivity to send
looper wake ups when new input is received (only sending a single wake
up, until the application next handles input).

When a wake up is received and we recognise that new input is available
then an `InputAvailable` event is sent to the application - consistent
with how NativeActivity can deliver `InputAvailable` events.

This addresses a significant feature disparity between GameActivity and
NativeActivity that meant GameActivity was not practically usable for
GUI applications that wouldn't want to render continuously like a game.

Addresses #4
2022-08-13 20:26:00 +01:00
Robert Bragg 00b116bcfe Factor out shared try_get_path_from_ptr utility API 2022-08-13 04:02:59 +01:00
John Kåre Alsaker dfc58b49fb Link the C++ standard library correctly. 2022-08-13 03:38:06 +01:00
Robert Bragg ecd03edb1a Add minimal Cpal audio library example
Based on the android example that's in the cpal repo, this test plays
a 440hz sine wave and is based on GameActivity

Note: this requires a workaround branch for cpal that comments out
a dev-dependency on ndk-glue that cpal has for its android example.
This is needed because Cargo is spuriously propagating this dev
dependency outside of the cpal package (which leads to a crash)
2022-08-12 19:28:48 +01:00
Robert Bragg 04c9060329 cargo fmt 2022-08-12 19:20:09 +01:00
Robert Bragg f22d8bbd30 Update generated NDK bindings 2022-08-12 19:10:31 +01:00
Robert Bragg 93828a18a9 Use NativeWindow::clone_from_ptr() to avoid Segfault
Since f24606cc84 in android-ndk-rs then NativeWindow now implements
Clone and Drop which was technically a breaking change since it
changed the ownership contract for existing users of
NativeWindow::from_ptr().

We now use NativeWindow::clone_from_ptr() to account for the fact that
the window will be unconditionally _released() when NativeWindow gets
dropped.

This addresses a crash I was debugging with the Cpal and Oboe
examples which turned out to be nothing to do with the examples
themselves.
2022-08-12 19:10:30 +01:00
Robert Bragg 4818de6709 examples: force Winit to use in-tree android-activity
This fixes build errors about not specifying either of the
"native-activity" or "game-activity" features.

The issue came about because the in-tree examples want to
build against the in-tree version of android-activity located
with a relative `path = ` but these particular examples
depend on Winit which would resolve a second implementation
of android-activity, via a github url - where Cargo will treat
them as completely different crates.
2022-08-12 02:08:44 +01:00
Robert Bragg 190a3b91e7 CStr::from_ptr may expect *i8 or *u8 depending on target 2022-08-12 02:08:44 +01:00
Robert Bragg f54eaa2997 native-activity: coerce savedStateSize with
The type may have different sizes depending on the build target
2022-08-12 02:08:44 +01:00
Robert Bragg 7a77402279 native-activity: Fix InputAvailable support
"native-activity" builds were recently broken by bb8eeb705c which
this patch fixes.

The na-mainloop example has also been updated to verify this by
reducing the fake "render" timeout and also triggering a fake
render when an InputAvailable event is received.

Fixes: #12
2022-08-12 02:08:44 +01:00
Robert Bragg 0d0c10ebb2 Runs cargo fmt across everything 2022-08-11 23:16:55 +01:00
Robert Bragg 5220d35373 Don't depend on a specific micro version of libc 2022-08-11 23:16:46 +01:00
Robert Bragg b05dcb6d44 Merge pull request #9 from Zoxc/ci
Add some initial CI support
2022-08-11 22:16:50 +01:00
Robert Bragg e4608b0791 agdk-winit-wgpu: update to wgpu 0.13 2022-08-11 03:37:22 +01:00
Robert Bragg ce36c38934 Update to expect 0.27 based Winit branch
While egui hasn't yet merged its Winit 0.27 support into master
agdk-egui currently points to an egui branch with Winit 0.27 support
2022-08-11 03:36:02 +01:00
Robert Bragg 7a49db4d61 Update to ndk 0.7 and ndk-sys 0.4 2022-08-11 03:32:28 +01:00
Robert Bragg 73a1acb3c7 examples: bump gradle-wrapper to fetch gradle-7.5-bin.zip 2022-08-11 03:12:33 +01:00
Robert Bragg b07717d8ac Merge pull request #8 from Zoxc/misc-fixes
Misc agdk-egui fixes
2022-08-11 02:12:37 +01:00
John Kåre Alsaker 8601f28eba Split formatting to a separate job 2022-08-11 01:04:09 +02:00
John Kåre Alsaker 49c877085b Fix indentation 2022-08-11 00:55:04 +02:00
John Kåre Alsaker 9e3d8fd977 Add CI 2022-08-11 00:04:53 +02:00
John Kåre Alsaker 5a7bc64bb1 Fix types 2022-08-09 23:05:02 +02:00
John Kåre Alsaker 114e249cbd Fix egui build 2022-08-09 22:44:50 +02:00
John Kåre Alsaker 875952b2a9 Update Gradle to build with Java 18 2022-08-09 22:44:04 +02:00
John Kåre Alsaker b1b7f49c7e Add target/ to .gitignore 2022-08-09 22:43:22 +02:00
Robert Bragg 19c989c640 agdk-mainloop: fix features declaration 2022-07-26 02:03:36 +01:00
Robert Bragg 6278b54494 agdk-winit-wgpu: fix use of android_activity
Fixes issue raised in #6 by @tschrpl
2022-07-26 02:00:24 +01:00
Robert Bragg a73f9202d0 Add minimal Oboe audio library example
Based on the demo in the oboe-rs repo this is a minimal example that
runs with GameActivity and plays a 440Hz sine wave
2022-07-26 01:31:56 +01:00
Robert Bragg bb8eeb705c native-activity: emit an InputAvailable event for new input
This reinstates support for notifying applications of new input events
without requiring them to always check for input as part of their
rendering updates. This makes it possible to build UI applications that
might only need to redraw in response to new input.

For now GameActivity doesn't emit this event but the plan is to also
add support for this in GameActivity.

Addresses: #4
2022-07-06 15:26:14 +01:00