Commit Graph

72 Commits

Author SHA1 Message Date
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
Robert Bragg 1ca5f13874 android_native_app_glue: expose helpers for attaching input queue to looper 2022-07-06 15:26:14 +01:00
Robert Bragg eda89d0e15 generate-bindings: use ANDROID_NDK_HOME if set 2022-07-06 14:58:29 +01:00
Robert Bragg a8e8017918 Bump ndk/ndk-sys deps for consistency with winit master v0.1.1 2022-07-04 20:54:20 +01:00
Robert Bragg a8c0e37d80 Fix for generate-bindings.sh and updates generated ffi bindings 2022-07-04 20:40:03 +01:00
Robert Bragg 3f06bce6ce Cargo.toml: Add docs.rs link 2022-07-04 19:39:03 +01:00
Robert Bragg 74b2f22494 docs: generate docs as if native-activity feature enabled 2022-07-04 02:39:59 +01:00
Robert Bragg ffaabf09c8 Cargo.toml tweaks for publishing v0.1.0 2022-07-04 00:21:29 +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 12aa17ee42 Remove redundant game-activity + native-activity crates 2022-07-03 22:18:46 +01:00
Robert Bragg 86a4ba1662 Adds configurable android-activity crate
This general Activity glue crate now supersedes the two separate
native-activity and game-activity crates.

The adds the functionality of both crates as modules within this
new crate but provides a single crate + API that downstream can
depend on as an Activity glue layer.

The new crate exposes two (mutually-exclusive) features for
choosing which Activity backend to build:
* "native-activity"
* "game-activity"

This common crate makes it more practical to write code that's
Activity agnostic.
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 0565ae01ec Expose native_window() via AndroidApp instead of static
To be able to support multiple activities per-process we can't have any
static/global state.
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 864d782c24 Attach native thread to JVM before calling android_main 2022-05-28 02:54:00 +01:00
Robert Bragg c492fead0f App: Expose internal/ext/obb paths + sdk_version
This exposes the state from ANativeActivity and GameActivity in a
portable (Activity agnostic) way.
2022-05-28 02:53:59 +01:00
Robert Bragg 2a8fc83ea2 build.rs: disable 'extra' warnings 2022-05-28 02:53:59 +01:00
Robert Bragg 73d56ede5f GameActivity PATCH: remove unused variable 2022-05-28 02:53:59 +01:00
Robert Bragg a0f52a2398 GameActivity PATCH: sync with upstream 2022-05-28 02:53:59 +01:00
Robert Bragg d929a88468 README: add adb logcat command to initial example 2022-05-25 22:30:23 +01:00
Robert Bragg 5d38fdf593 A few minor simplifications of the *-mainloop examples 2022-05-25 22:27:53 +01:00
Robert Bragg 4f8227b5ba Add an initial top-level README 2022-05-25 20:19:34 +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