initial commit
This commit is contained in:
@@ -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