initial commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/target
|
||||
Generated
+3967
File diff suppressed because it is too large
Load Diff
+36
@@ -0,0 +1,36 @@
|
||||
[package]
|
||||
name = "egui_android_template"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
egui = { version = "0.33.2", default-features = false, features = [
|
||||
"default_fonts",
|
||||
"rayon",
|
||||
] }
|
||||
|
||||
log = "0.4"
|
||||
|
||||
[target.'cfg(not(target_os="android"))'.dependencies]
|
||||
eframe = { version = "0.33.2", default-features = false, features = [
|
||||
"default_fonts",
|
||||
"glow",
|
||||
"wayland",
|
||||
"x11",
|
||||
"accesskit",
|
||||
] }
|
||||
|
||||
[target.'cfg(target_os="android")'.dependencies]
|
||||
winit = { version = "0.30.12", features = ["android-native-activity"] }
|
||||
eframe = { version = "0.33.2", default-features = false, features = [
|
||||
"default_fonts",
|
||||
"glow",
|
||||
"android-native-activity",
|
||||
] }
|
||||
|
||||
android_logger = "0.13"
|
||||
android-activity = { version = "0.6.0", features = ["native-activity"] }
|
||||
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
@@ -0,0 +1,9 @@
|
||||
Build on PC
|
||||
```bash
|
||||
cargo build
|
||||
```
|
||||
|
||||
Build on android (using xbuild)
|
||||
```bash
|
||||
x build --platform android --arch arm64 --format apk --release
|
||||
```
|
||||
@@ -0,0 +1,29 @@
|
||||
use eframe::{App, Frame, NativeOptions};
|
||||
use egui::{CentralPanel, Context};
|
||||
use std::error::Error;
|
||||
|
||||
pub struct Application {}
|
||||
|
||||
impl Application {
|
||||
pub fn new() -> Self {
|
||||
Application {}
|
||||
}
|
||||
}
|
||||
|
||||
impl App for Application {
|
||||
fn update(&mut self, ctx: &Context, _frame: &mut Frame) {
|
||||
CentralPanel::default().show(ctx, |_ui| {});
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(options: NativeOptions) -> Result<(), Box<dyn Error>> {
|
||||
match eframe::run_native(
|
||||
"EGUI Android Example",
|
||||
options,
|
||||
Box::new(|_cc| Ok(Box::new(Application::new()))),
|
||||
) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#![cfg(target_os = "android")]
|
||||
mod gui;
|
||||
|
||||
use eframe::{HardwareAcceleration, NativeOptions};
|
||||
use egui::ViewportBuilder;
|
||||
use winit::platform::android::activity::AndroidApp;
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
fn android_main(app: AndroidApp) -> Result<(), Box<dyn Error>> {
|
||||
android_logger::init_once(
|
||||
android_logger::Config::default().with_max_level(log::LevelFilter::Warn),
|
||||
);
|
||||
|
||||
let opts = NativeOptions {
|
||||
android_app: Some(app),
|
||||
vsync: true,
|
||||
centered: true,
|
||||
hardware_acceleration: HardwareAcceleration::Preferred,
|
||||
|
||||
viewport: ViewportBuilder::default().with_app_id("com.example.egui"),
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
gui::run(opts)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#[cfg(not(target_os = "android"))]
|
||||
pub mod gui;
|
||||
|
||||
use eframe::{HardwareAcceleration, NativeOptions};
|
||||
use egui::ViewportBuilder;
|
||||
use std::error::Error;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let opts = NativeOptions {
|
||||
vsync: true,
|
||||
centered: true,
|
||||
hardware_acceleration: HardwareAcceleration::Preferred,
|
||||
|
||||
viewport: ViewportBuilder::default().with_app_id("com.example.egui"),
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
gui::run(opts)
|
||||
}
|
||||
Reference in New Issue
Block a user