Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions agdk-cpal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "agdk-cpal"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
2 changes: 1 addition & 1 deletion agdk-cpal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This is a minimal test application based on `GameActivity` that just
runs a mainloop based on android_activity::poll_events() and plays a
sine wave audio test using the Cpal audio library.

```
```bash
export ANDROID_NDK_HOME="path/to/ndk"
export ANDROID_HOME="path/to/sdk"

Expand Down
10 changes: 5 additions & 5 deletions agdk-cpal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
///! Based on https://github.com/RustAudio/cpal/blob/master/examples/android.rs
use android_activity::{AndroidApp, InputStatus, MainEvent, PollEvent};
//! Based on https://github.com/RustAudio/cpal/blob/master/examples/android.rs

use std::sync::OnceLock;
use tracing::{error, info};

use android_activity::{AndroidApp, InputStatus, MainEvent, PollEvent};
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
SizedSample,
FromSample, Sample, SizedSample,
};
use cpal::{FromSample, Sample};
use tracing::{error, info};

fn write_data<T>(output: &mut [T], channels: usize, next_sample: &mut dyn FnMut() -> f32)
where
Expand Down
2 changes: 0 additions & 2 deletions agdk-eframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ version = "0.1.0"
edition = "2021"
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
2 changes: 1 addition & 1 deletion agdk-eframe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This tests using `GameActivity` with egui, winit and wgpu.
This is based on a re-worked winit backend here:
https://github.com/rib/winit/tree/android-activity

```
```bash
export ANDROID_NDK_HOME="path/to/ndk"
export ANDROID_HOME="path/to/sdk"

Expand Down
4 changes: 1 addition & 3 deletions agdk-eframe/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use eframe::egui;
use eframe::{NativeOptions, Renderer};
use eframe::{egui, NativeOptions, Renderer};
use tracing::{error, info};

#[cfg(target_os = "android")]
use winit::platform::android::activity::AndroidApp;

Expand Down
2 changes: 0 additions & 2 deletions agdk-egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ version = "0.1.0"
edition = "2021"
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
19 changes: 7 additions & 12 deletions agdk-egui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#[cfg(target_os = "android")]
use std::sync::OnceLock;
use std::{num::NonZeroU32, sync::Arc};
use tracing::{debug, error};

use egui::ViewportId;
use egui_wgpu::RendererOptions;
use egui_winit::winit;

use winit::event_loop::{ActiveEventLoop, EventLoop};

use egui_wgpu::{winit::Painter, RendererOptions};
use egui_winit::{winit, State};
use tracing::{debug, error};
#[cfg(target_os = "android")]
use winit::platform::android::activity::AndroidApp;

use winit::event_loop::ControlFlow;

use egui_wgpu::winit::Painter;
use egui_winit::State;
use winit::event::Event::*;
use winit::{
event::Event::*,
event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
};
const INITIAL_WIDTH: u32 = 1920;
const INITIAL_HEIGHT: u32 = 1080;

Expand Down
2 changes: 0 additions & 2 deletions agdk-mainloop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "agdk-mainloop"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
2 changes: 1 addition & 1 deletion agdk-mainloop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ runs a mainloop based on android_activity::poll_events() and traces
the events received without doing any rendering. It also saves and
restores some minimal application state.

```
```bash
export ANDROID_NDK_HOME="path/to/ndk"
export ANDROID_HOME="path/to/sdk"

Expand Down
3 changes: 2 additions & 1 deletion agdk-mainloop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ fn android_main(app: AndroidApp) {
}
InputEvent::MotionEvent(motion_event) => {
println!("action = {:?}", motion_event.action());
#[expect(clippy::single_match)]
match motion_event.action() {
MotionAction::Up => {
let pointer = motion_event.pointer_index();
Expand Down Expand Up @@ -367,7 +368,7 @@ fn character_map_and_combine_key(
Some(unicode)
};
*combining_accent = None;
combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode))
combined_unicode.map(KeyMapChar::Unicode)
} else {
Some(KeyMapChar::Unicode(unicode))
}
Expand Down
4 changes: 1 addition & 3 deletions agdk-oboe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "agdk-oboe"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log = "0.4"
android_logger = "0.13.1"
Expand All @@ -14,4 +12,4 @@ atomic_float = "0.1"

[lib]
name="main"
crate_type=["cdylib"]
crate_type=["cdylib"]
2 changes: 1 addition & 1 deletion agdk-oboe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This is a minimal test application based on `GameActivity` that just
runs a mainloop based on android_activity::poll_events() and plays a
sine wave audio test using the Oboe audio library.

```
```bash
export ANDROID_NDK_HOME="path/to/ndk"
export ANDROID_HOME="path/to/sdk"

Expand Down
2 changes: 1 addition & 1 deletion agdk-oboe/src/audio.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use atomic_float::AtomicF32;
use std::{
f32::consts::PI,
marker::PhantomData,
sync::{atomic::Ordering, Arc},
};

use atomic_float::AtomicF32;
use oboe::{
AudioDeviceDirection, AudioDeviceInfo, AudioFeature, AudioOutputCallback, AudioOutputStream,
AudioOutputStreamSafe, AudioStream, AudioStreamAsync, AudioStreamBase, AudioStreamBuilder,
Expand Down
2 changes: 0 additions & 2 deletions agdk-winit-wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "agdk-winit-wgpu"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
18 changes: 8 additions & 10 deletions agdk-winit-wgpu/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
use std::borrow::Cow;
#[cfg(target_os = "android")]
use std::ffi::c_void;
#[cfg(target_os = "android")]
use std::ptr::NonNull;
use std::sync::Arc;

use tracing::{error, info, trace, warn};
use std::{borrow::Cow, sync::Arc};

use raw_window_handle::{HandleError, HasDisplayHandle, HasWindowHandle};
use wgpu::{Adapter, Device, Instance, PipelineLayout, Queue, RenderPipeline, ShaderModule};
use wgpu::{PipelineCompilationOptions, TextureFormat};

use winit::error::EventLoopError;
use winit::event_loop::{EventLoop, EventLoopProxy};
use tracing::{error, info, trace, warn};
use wgpu::{
Adapter, Device, Instance, PipelineCompilationOptions, PipelineLayout, Queue, RenderPipeline,
ShaderModule, TextureFormat,
};
use winit::{
error::EventLoopError,
event::{Event, WindowEvent},
event_loop::{ActiveEventLoop, ControlFlow},
event_loop::{ActiveEventLoop, ControlFlow, EventLoop, EventLoopProxy},
};

#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions agdk-winit-wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ mod app;
#[cfg(target_os = "android")]
#[unsafe(no_mangle)]
fn android_main(app: AndroidApp) {
use app::App;
use std::sync::OnceLock;

use app::App;
use tracing::error;
use winit::event_loop::EventLoop;
use winit::platform::android::EventLoopBuilderExtAndroid;
use winit::{event_loop::EventLoop, platform::android::EventLoopBuilderExtAndroid};

std::env::set_var("RUST_BACKTRACE", "full");
std::env::set_var("WGPU_BACKEND", "vulkan");
Expand Down
9 changes: 3 additions & 6 deletions agdk-winit-wgpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ mod app;
#[cfg(target_arch = "wasm32")]
pub fn main() {
use app::App;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use winit::event_loop::EventLoop;
use winit::platform::web::EventLoopExtWebSys;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use winit::{event_loop::EventLoop, platform::web::EventLoopExtWebSys};

console_error_panic_hook::set_once();

Expand Down Expand Up @@ -52,9 +50,8 @@ use winit::error::EventLoopError;
#[allow(dead_code)]
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
fn main() -> Result<(), EventLoopError> {
use winit::event_loop::EventLoop;

use app::App;
use winit::event_loop::EventLoop;

if std::option_env!("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", app::DEFAULT_ENV_FILTER);
Expand Down
2 changes: 0 additions & 2 deletions na-egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ version = "0.1.0"
edition = "2021"
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
20 changes: 8 additions & 12 deletions na-egui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
use std::{num::NonZeroU32, sync::Arc};
use tracing::{debug, error};

use egui::ViewportId;
use egui_wgpu::RendererOptions;
use egui_winit::winit;

use winit::event_loop::{ActiveEventLoop, EventLoop};

use egui_wgpu::{winit::Painter, RendererOptions};
use egui_winit::{winit, State};
use tracing::{debug, error};
#[cfg(target_os = "android")]
use winit::platform::android::activity::AndroidApp;

use winit::event_loop::ControlFlow;

use egui_wgpu::winit::Painter;
use egui_winit::State;
use winit::event::Event::*;
use winit::{
event::Event::*,
event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
};
const INITIAL_WIDTH: u32 = 1920;
const INITIAL_HEIGHT: u32 = 1080;

Expand Down Expand Up @@ -209,6 +204,7 @@ const DEFAULT_ENV_FILTER: &str = "debug,wgpu_hal=info,winit=info,naga=info";
#[no_mangle]
fn android_main(app: AndroidApp) {
use std::sync::OnceLock;

use winit::platform::android::EventLoopBuilderExtAndroid;

std::env::set_var("RUST_BACKTRACE", "full");
Expand Down
2 changes: 0 additions & 2 deletions na-mainloop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "na-mainloop"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
#log = "0.4"
#android_logger = "0.11.0"
Expand Down
5 changes: 3 additions & 2 deletions na-mainloop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Since this test doesn't require a custom `Activity` subclass it's
optionally possible to build this example with `cargo apk`.

# Gradle Build
```
```bash
export ANDROID_NDK_HOME="path/to/ndk"
export ANDROID_HOME="path/to/sdk"

Expand All @@ -26,7 +26,8 @@ adb shell am start -n com.github.realfit_mobile.namainloop/android.app.NativeAct
```

# Cargo APK Build
```

```bash
export ANDROID_NDK_HOME="path/to/ndk"
export ANDROID_SDK_HOME="path/to/sdk"

Expand Down
6 changes: 3 additions & 3 deletions na-mainloop/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::sync::OnceLock;

use android_activity::{
AndroidApp, InputStatus, MainEvent, OnCreateState, PollEvent,
input::{InputEvent, KeyAction, KeyEvent, KeyMapChar, MotionAction},
ndk, ndk_sys,
ndk, ndk_sys, AndroidApp, InputStatus, MainEvent, OnCreateState, PollEvent,
};
use jni::{
objects::{JObject, JString},
Expand Down Expand Up @@ -228,6 +227,7 @@ fn android_main(app: AndroidApp) {
}
InputEvent::MotionEvent(motion_event) => {
println!("action = {:?}", motion_event.action());
#[expect(clippy::single_match)]
match motion_event.action() {
MotionAction::Up => {
let pointer = motion_event.pointer_index();
Expand Down Expand Up @@ -368,7 +368,7 @@ fn character_map_and_combine_key(
Some(unicode)
};
*combining_accent = None;
combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode))
combined_unicode.map(KeyMapChar::Unicode)
} else {
Some(KeyMapChar::Unicode(unicode))
}
Expand Down
20 changes: 9 additions & 11 deletions na-openxr-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "na-openxr-info"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log = "0.4"
openxr = { version = "0.17" }
Expand All @@ -17,17 +15,17 @@ android_logger = "0.11.0"
android-activity = { version = "0.4", features = ["native-activity"] }

[features]
default = [ "linked" ]
default = ["linked"]

android = [ "openxr/linked" ]
desktop = [ "linked", "openxr/static"]
linked = []
android = ["linked"]
desktop = ["linked", "openxr/static"]
linked = ["openxr/linked"]

[lib]
name="main"
crate_type=["cdylib"]
name = "main"
crate_type = ["cdylib"]

[[bin]]
path="src/lib.rs"
name="test-winit-wgpu"
required-features = [ "desktop" ]
path = "src/lib.rs"
name = "test-winit-wgpu"
required-features = ["desktop"]
Loading
Loading