38 Commits

Author SHA1 Message Date
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 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 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 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 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 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 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 73a1acb3c7 examples: bump gradle-wrapper to fetch gradle-7.5-bin.zip 2022-08-11 03:12:33 +01: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
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 b63b5e15fa Update READMEs 2022-07-03 23:34:25 +01:00
Robert Bragg 2264826535 Update examples to use android_activity 2022-07-03 22:18:46 +01:00
Robert Bragg d4459921b9 Remove global android_app() API
android_main() now takes an `app: AndroidApp` argument and has an
extern "Rust" ABI instead of "C" ABI.

This should help make it possible to run multiple native Activities in a
single process.
2022-07-03 22:18:45 +01:00
Robert Bragg 70e33c9635 na-subclass-jni example: add ndk-context dep 2022-07-03 22:18:45 +01:00
Robert Bragg 5d38fdf593 A few minor simplifications of the *-mainloop examples 2022-05-25 22:27:53 +01:00
Robert Bragg 99fc467be0 Add minimal NativeActivity subclass example with JNI 2022-05-23 01:58:57 +01:00
Robert Bragg 084b807319 agdk-egui: build with upstream master branch 2022-05-23 01:51:50 +01:00
Robert Bragg 2f3dbf12a6 add android:configChanges to manifests + remove some unused xml 2022-05-23 01:43:03 +01:00
Robert Bragg 9ac0e2f6e2 na-winit-wgpu: don't look for winit crate locally by default 2022-05-20 05:03:47 +01:00
Robert Bragg bab9bcf104 Add na-winit-wgpu example based on NativeActivity 2022-05-20 04:07:29 +01:00
Robert Bragg 19784d95e3 Add minimal mainloop example based on NativeActivity 2022-05-20 04:07:23 +01:00
Robert Bragg 316021e4ac agdk-winit-wgpu: use env_logger if not on Android 2022-05-20 02:46:38 +01:00
Robert Bragg 164957ec65 game-activity: rework input API
This leaves the InputBuffer abstraction as an implementation detail
and just exposes an API like this for processing input:

  app.input_events(|event| {
      // handle event
  });

The main consideration here was to have an API that could also be
supported via NativeActivity to keep open the possibility of a standard
Android 'glue' API.
2022-05-20 02:46:01 +01:00
Robert Bragg 69d0de4db1 agdk-egui: use upstream egui-winit + egui-wgpu crates
The functionality found in egui_winit_platform and egui_wgpu_backend is
now available in the upstream egui-winit and egui-wgpu crates
respectively.

This has simplified the example itself and also removed the dependency
on epi.

The example is now based on egui 0.18 (was previously 0.17)

Since the upstream egui-winit/wgpu crates were generally assuming that
the graphics context and surface can be initialized immediately this
currently builds against a branch that aims to upstream changes that
remove these assumptions:

https://github.com/rib/egui/tree/android-deferred-winit-wgpu
Ref: https://github.com/emilk/egui/pull/1634
2022-05-17 18:20:25 +01:00
Robert Bragg bfc0d091e6 Add a minimal Egui + Winit + WGPU based example 2022-05-13 20:13:30 +01:00
Robert Bragg 74e8ff645a Remove unused src/shader.wgsl from agdk-mainloop example 2022-05-10 03:08:56 +01:00
Robert Bragg 915f7382e5 Add a minimal Winit and WGPU based example 2022-05-10 02:04:25 +01:00
Robert Bragg 02dda282d0 Add basic agdk-mainloop example 2022-05-10 02:00:47 +01:00