[refactor] rename 'example' to 'demo', and add simple example_glium
This commit is contained in:
parent
bf19eb2ec5
commit
61cdec8fca
20 changed files with 235 additions and 148 deletions
81
Cargo.lock
generated
81
Cargo.lock
generated
|
@ -375,6 +375,27 @@ dependencies = [
|
||||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "demo_glium"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"egui 0.1.2 (git+https://github.com/emilk/emigui)",
|
||||||
|
"egui_glium 0.1.0 (git+https://github.com/emilk/emigui)",
|
||||||
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "demo_web"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"egui 0.1.2 (git+https://github.com/emilk/emigui)",
|
||||||
|
"egui_web 0.1.0 (git+https://github.com/emilk/emigui)",
|
||||||
|
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derivative"
|
name = "derivative"
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
|
@ -403,6 +424,17 @@ name = "downcast-rs"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "egui"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "git+https://github.com/emilk/emigui#3552f7f82861fb10ae646c61f3c283256e79940e"
|
||||||
|
dependencies = [
|
||||||
|
"ahash 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"parking_lot 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rusttype 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui"
|
name = "egui"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
|
@ -414,6 +446,20 @@ dependencies = [
|
||||||
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "egui_glium"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/emilk/emigui#3552f7f82861fb10ae646c61f3c283256e79940e"
|
||||||
|
dependencies = [
|
||||||
|
"chrono 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"egui 0.1.2 (git+https://github.com/emilk/emigui)",
|
||||||
|
"glium 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"webbrowser 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui_glium"
|
name = "egui_glium"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -427,6 +473,20 @@ dependencies = [
|
||||||
"webbrowser 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"webbrowser 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "egui_web"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/emilk/emigui#3552f7f82861fb10ae646c61f3c283256e79940e"
|
||||||
|
dependencies = [
|
||||||
|
"egui 0.1.2 (git+https://github.com/emilk/emigui)",
|
||||||
|
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"parking_lot 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui_web"
|
name = "egui_web"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -449,23 +509,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
name = "example_glium"
|
name = "example_glium"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"egui 0.1.2",
|
"egui 0.1.2 (git+https://github.com/emilk/emigui)",
|
||||||
"egui_glium 0.1.0",
|
"egui_glium 0.1.0 (git+https://github.com/emilk/emigui)",
|
||||||
"glium 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "example_wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"egui 0.1.2",
|
|
||||||
"egui_web 0.1.0",
|
|
||||||
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1681,6 +1727,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum dispatch 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
"checksum dispatch 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
|
||||||
"checksum dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
|
"checksum dlib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
|
||||||
"checksum downcast-rs 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
"checksum downcast-rs 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||||
|
"checksum egui 0.1.2 (git+https://github.com/emilk/emigui)" = "<none>"
|
||||||
|
"checksum egui_glium 0.1.0 (git+https://github.com/emilk/emigui)" = "<none>"
|
||||||
|
"checksum egui_web 0.1.0 (git+https://github.com/emilk/emigui)" = "<none>"
|
||||||
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
||||||
"checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
"checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -1,12 +1,19 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"egui",
|
"demo_glium",
|
||||||
"egui_glium",
|
"egui_glium",
|
||||||
"egui_web",
|
"egui_web",
|
||||||
|
"egui",
|
||||||
"example_glium",
|
"example_glium",
|
||||||
"example_wasm",
|
"demo_web",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
egui = { path = 'egui' }
|
||||||
|
egui_glium = { path = 'egui_glium' }
|
||||||
|
egui_web = { path = 'egui_web' }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
# lto = true # VERY slightly smaller wasm
|
# lto = true # VERY slightly smaller wasm
|
||||||
# opt-level = 's' # 10-20% smaller wasm compared to `opt-level = 3`
|
# opt-level = 's' # 10-20% smaller wasm compared to `opt-level = 3`
|
||||||
|
|
|
@ -5,4 +5,4 @@ cargo fmt --all -- --check
|
||||||
cargo check --all-features
|
cargo check --all-features
|
||||||
cargo clippy
|
cargo clippy
|
||||||
|
|
||||||
cargo run --bin example_glium --release
|
cargo run --bin demo_glium --release
|
||||||
|
|
|
@ -16,11 +16,11 @@ BUILD=release
|
||||||
rm -rf docs/*.wasm
|
rm -rf docs/*.wasm
|
||||||
|
|
||||||
echo "Build rust:"
|
echo "Build rust:"
|
||||||
cargo build --release -p example_wasm --target wasm32-unknown-unknown
|
cargo build --release -p demo_web --target wasm32-unknown-unknown
|
||||||
|
|
||||||
echo "Generate JS bindings for wasm:"
|
echo "Generate JS bindings for wasm:"
|
||||||
FOLDER_NAME=${PWD##*/}
|
FOLDER_NAME=${PWD##*/}
|
||||||
TARGET_NAME="example_wasm.wasm"
|
TARGET_NAME="demo_web.wasm"
|
||||||
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
||||||
--out-dir docs --no-modules --no-typescript
|
--out-dir docs --no-modules --no-typescript
|
||||||
|
|
||||||
|
|
11
demo_glium/Cargo.toml
Normal file
11
demo_glium/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "demo_glium"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
egui = { git = "https://github.com/emilk/emigui", features = ["with_serde"] }
|
||||||
|
egui_glium = { git = "https://github.com/emilk/emigui" }
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
70
demo_glium/src/main.rs
Normal file
70
demo_glium/src/main.rs
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#![deny(warnings)]
|
||||||
|
#![warn(clippy::all)]
|
||||||
|
|
||||||
|
use egui_glium::{persistence::Persistence, RunMode, Runner};
|
||||||
|
|
||||||
|
const APP_KEY: &str = "app";
|
||||||
|
|
||||||
|
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
||||||
|
struct MyApp {
|
||||||
|
egui_demo_app: egui::DemoApp,
|
||||||
|
frames_painted: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl egui_glium::App for MyApp {
|
||||||
|
fn ui(&mut self, ui: &mut egui::Ui, runner: &mut Runner) {
|
||||||
|
self.egui_demo_app.ui(ui, "");
|
||||||
|
|
||||||
|
use egui::*;
|
||||||
|
let mut ui = ui.centered_column(ui.available().width().min(480.0));
|
||||||
|
ui.set_layout(Layout::vertical(Align::Min));
|
||||||
|
ui.add(label!("Egui inside of Glium").text_style(TextStyle::Heading));
|
||||||
|
if ui.add(Button::new("Quit")).clicked {
|
||||||
|
runner.quit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.add(
|
||||||
|
label!(
|
||||||
|
"CPU usage: {:.2} ms / frame (excludes painting)",
|
||||||
|
1e3 * runner.cpu_time()
|
||||||
|
)
|
||||||
|
.text_style(TextStyle::Monospace),
|
||||||
|
);
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
let mut run_mode = runner.run_mode();
|
||||||
|
ui.label("Run mode:");
|
||||||
|
ui.radio_value("Continuous", &mut run_mode, RunMode::Continuous)
|
||||||
|
.tooltip_text("Repaint everything each frame");
|
||||||
|
ui.radio_value("Reactive", &mut run_mode, RunMode::Reactive)
|
||||||
|
.tooltip_text("Repaint when there are animations or input (e.g. mouse movement)");
|
||||||
|
runner.set_run_mode(run_mode);
|
||||||
|
});
|
||||||
|
|
||||||
|
if runner.run_mode() == RunMode::Continuous {
|
||||||
|
ui.add(
|
||||||
|
label!("Repainting the UI each frame. FPS: {:.1}", runner.fps())
|
||||||
|
.text_style(TextStyle::Monospace),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ui.label("Only running UI code when there are animations or input");
|
||||||
|
}
|
||||||
|
|
||||||
|
self.frames_painted += 1;
|
||||||
|
ui.label(format!("Total frames painted: {}", self.frames_painted));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_exit(&mut self, persistence: &mut Persistence) {
|
||||||
|
persistence.set_value(APP_KEY, self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let title = "Egui glium demo";
|
||||||
|
let persistence = Persistence::from_path(".egui_demo_glium.json".into());
|
||||||
|
let app: MyApp = persistence.get_value(APP_KEY).unwrap_or_default();
|
||||||
|
egui_glium::run(title, RunMode::Reactive, persistence, app);
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "example_wasm"
|
name = "demo_web"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
@ -9,10 +9,9 @@ edition = "2018"
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
egui = { git = "https://github.com/emilk/emigui", features = ["with_serde"] }
|
||||||
|
egui_web = { git = "https://github.com/emilk/emigui" }
|
||||||
js-sys = "0.3"
|
js-sys = "0.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
|
|
||||||
egui = { path = "../egui" }
|
|
||||||
egui_web = { path = "../egui_web" }
|
|
|
@ -21,7 +21,7 @@ pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct MyApp {
|
pub struct MyApp {
|
||||||
example_app: egui::examples::ExampleApp,
|
demo_app: egui::demos::DemoApp,
|
||||||
frames_painted: u64,
|
frames_painted: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,6 @@ impl egui_web::App for MyApp {
|
||||||
self.window_ui(ui, backend);
|
self.window_ui(ui, backend);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.example_app.ui(ui, &info.web_location_hash);
|
self.demo_app.ui(ui, &info.web_location_hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -207,26 +207,26 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
||||||
real.original = state;
|
real.original = state;
|
||||||
return real;
|
return real;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_26(arg0, arg1) {
|
function __wbg_adapter_26(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h84da5f062b972f09(arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_29(arg0, arg1, arg2) {
|
function __wbg_adapter_29(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_32(arg0, arg1, arg2) {
|
function __wbg_adapter_32(arg0, arg1) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
|
||||||
}
|
|
||||||
|
|
||||||
function __wbg_adapter_35(arg0, arg1) {
|
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5402719cc6dde927(arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5402719cc6dde927(arg0, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_38(arg0, arg1, arg2) {
|
function __wbg_adapter_35(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __wbg_adapter_38(arg0, arg1) {
|
||||||
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h84da5f062b972f09(arg0, arg1);
|
||||||
|
}
|
||||||
|
|
||||||
function __wbg_adapter_41(arg0, arg1, arg2) {
|
function __wbg_adapter_41(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h22fd33d9f501a695(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
@ -423,14 +423,6 @@ async function init(input) {
|
||||||
var ret = getObject(arg0) instanceof WebGLRenderingContext;
|
var ret = getObject(arg0) instanceof WebGLRenderingContext;
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
imports.wbg.__wbg_drawingBufferWidth_d15574dca0dbf918 = function(arg0) {
|
|
||||||
var ret = getObject(arg0).drawingBufferWidth;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
imports.wbg.__wbg_drawingBufferHeight_64716b9e5a2d23f9 = function(arg0) {
|
|
||||||
var ret = getObject(arg0).drawingBufferHeight;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
imports.wbg.__wbg_bufferData_7c335d1d31ac7268 = function(arg0, arg1, arg2, arg3) {
|
imports.wbg.__wbg_bufferData_7c335d1d31ac7268 = function(arg0, arg1, arg2, arg3) {
|
||||||
getObject(arg0).bufferData(arg1 >>> 0, getObject(arg2), arg3 >>> 0);
|
getObject(arg0).bufferData(arg1 >>> 0, getObject(arg2), arg3 >>> 0);
|
||||||
};
|
};
|
||||||
|
@ -725,28 +717,28 @@ async function init(input) {
|
||||||
var ret = wasm.memory;
|
var ret = wasm.memory;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper381 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper380 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_35);
|
var ret = makeMutClosure(arg0, arg1, 68, __wbg_adapter_26);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper385 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper370 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_38);
|
var ret = makeMutClosure(arg0, arg1, 68, __wbg_adapter_32);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper382 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper378 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_41);
|
var ret = makeMutClosure(arg0, arg1, 68, __wbg_adapter_41);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper387 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper376 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_26);
|
var ret = makeMutClosure(arg0, arg1, 68, __wbg_adapter_38);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper389 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper374 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_29);
|
var ret = makeMutClosure(arg0, arg1, 68, __wbg_adapter_35);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper391 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper371 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_32);
|
var ret = makeMutClosure(arg0, arg1, 68, __wbg_adapter_29);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
|
@ -45,13 +45,13 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||||
<script src="example_wasm.js"></script>
|
<script src="demo_web.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// We'll defer our execution until the wasm is ready to go.
|
// We'll defer our execution until the wasm is ready to go.
|
||||||
// Here we tell bindgen the path to the wasm file so it can start
|
// Here we tell bindgen the path to the wasm file so it can start
|
||||||
// initialization and return to us a promise when it's done.
|
// initialization and return to us a promise when it's done.
|
||||||
wasm_bindgen("./example_wasm_bg.wasm")
|
wasm_bindgen("./demo_web_bg.wasm")
|
||||||
.then(on_wasm_loaded)["catch"](console.error);
|
.then(on_wasm_loaded)["catch"](console.error);
|
||||||
|
|
||||||
function on_wasm_loaded() {
|
function on_wasm_loaded() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
let mut example_app = egui::examples::ExampleApp::default();
|
let mut demo_app = egui::demos::DemoApp::default();
|
||||||
let mut ctx = egui::Context::new();
|
let mut ctx = egui::Context::new();
|
||||||
|
|
||||||
let raw_input = egui::RawInput {
|
let raw_input = egui::RawInput {
|
||||||
|
@ -9,10 +9,10 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
c.bench_function("example_app", |b| {
|
c.bench_function("demo_app", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut ui = ctx.begin_frame(raw_input.clone());
|
let mut ui = ctx.begin_frame(raw_input.clone());
|
||||||
example_app.ui(&mut ui, "");
|
demo_app.ui(&mut ui, "");
|
||||||
ctx.end_frame()
|
ctx.end_frame()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,6 @@ mod app;
|
||||||
mod fractal_clock;
|
mod fractal_clock;
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
app::{ExampleApp, ExampleWindow},
|
app::{DemoApp, DemoWindow},
|
||||||
fractal_clock::FractalClock,
|
fractal_clock::FractalClock,
|
||||||
};
|
};
|
|
@ -1,22 +1,20 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{color::*, containers::*, examples::FractalClock, widgets::*, *};
|
use crate::{color::*, containers::*, demos::FractalClock, widgets::*, *};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "with_serde", serde(default))]
|
#[cfg_attr(feature = "with_serde", serde(default))]
|
||||||
pub struct ExampleApp {
|
pub struct DemoApp {
|
||||||
previous_web_location_hash: String,
|
previous_web_location_hash: String,
|
||||||
|
|
||||||
open_windows: OpenWindows,
|
open_windows: OpenWindows,
|
||||||
// TODO: group the following together as ExampleWindows
|
demo_window: DemoWindow,
|
||||||
example_window: ExampleWindow,
|
|
||||||
fractal_clock: FractalClock,
|
fractal_clock: FractalClock,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExampleApp {
|
impl DemoApp {
|
||||||
/// `web_location_hash`: for web demo only. e.g. "#fragmet".
|
/// `web_location_hash`: for web demo only. e.g. "#fragmet".
|
||||||
pub fn ui(&mut self, ui: &mut Ui, web_location_hash: &str) {
|
pub fn ui(&mut self, ui: &mut Ui, web_location_hash: &str) {
|
||||||
if self.previous_web_location_hash != web_location_hash {
|
if self.previous_web_location_hash != web_location_hash {
|
||||||
|
@ -36,17 +34,17 @@ impl ExampleApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows(&mut self, ctx: &Arc<Context>) {
|
pub fn windows(&mut self, ctx: &Arc<Context>) {
|
||||||
let ExampleApp {
|
let DemoApp {
|
||||||
open_windows,
|
open_windows,
|
||||||
example_window,
|
demo_window,
|
||||||
fractal_clock,
|
fractal_clock,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
Window::new("Examples")
|
Window::new("Demo")
|
||||||
.open(&mut open_windows.examples)
|
.open(&mut open_windows.demo)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
example_window.ui(ui);
|
demo_window.ui(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
Window::new("Settings")
|
Window::new("Settings")
|
||||||
|
@ -76,8 +74,7 @@ impl ExampleApp {
|
||||||
|
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
struct OpenWindows {
|
struct OpenWindows {
|
||||||
// examples:
|
demo: bool,
|
||||||
examples: bool,
|
|
||||||
fractal_clock: bool,
|
fractal_clock: bool,
|
||||||
|
|
||||||
// egui stuff:
|
// egui stuff:
|
||||||
|
@ -89,7 +86,7 @@ struct OpenWindows {
|
||||||
impl Default for OpenWindows {
|
impl Default for OpenWindows {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
examples: true,
|
demo: true,
|
||||||
..OpenWindows::none()
|
..OpenWindows::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +95,7 @@ impl Default for OpenWindows {
|
||||||
impl OpenWindows {
|
impl OpenWindows {
|
||||||
fn none() -> Self {
|
fn none() -> Self {
|
||||||
Self {
|
Self {
|
||||||
examples: false,
|
demo: false,
|
||||||
fractal_clock: false,
|
fractal_clock: false,
|
||||||
|
|
||||||
settings: false,
|
settings: false,
|
||||||
|
@ -116,7 +113,7 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu::menu(ui, "Windows", |ui| {
|
menu::menu(ui, "Windows", |ui| {
|
||||||
ui.add(Checkbox::new(&mut windows.examples, "Examples"));
|
ui.add(Checkbox::new(&mut windows.demo, "Demo"));
|
||||||
ui.add(Checkbox::new(&mut windows.fractal_clock, "Fractal Clock"));
|
ui.add(Checkbox::new(&mut windows.fractal_clock, "Fractal Clock"));
|
||||||
ui.add(Separator::new());
|
ui.add(Separator::new());
|
||||||
ui.add(Checkbox::new(&mut windows.settings, "Settings"));
|
ui.add(Checkbox::new(&mut windows.settings, "Settings"));
|
||||||
|
@ -152,31 +149,31 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows) {
|
||||||
|
|
||||||
/// Showcase some ui code
|
/// Showcase some ui code
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct ExampleWindow {
|
pub struct DemoWindow {
|
||||||
num_columns: usize,
|
num_columns: usize,
|
||||||
|
|
||||||
widgets: Widgets,
|
widgets: Widgets,
|
||||||
layout: LayoutExample,
|
layout: LayoutDemo,
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
box_painting: BoxPainting,
|
box_painting: BoxPainting,
|
||||||
painting: Painting,
|
painting: Painting,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ExampleWindow {
|
impl Default for DemoWindow {
|
||||||
fn default() -> ExampleWindow {
|
fn default() -> DemoWindow {
|
||||||
ExampleWindow {
|
DemoWindow {
|
||||||
num_columns: 2,
|
num_columns: 2,
|
||||||
|
|
||||||
widgets: Default::default(),
|
widgets: Default::default(),
|
||||||
layout: Default::default(),
|
layout: Default::default(),
|
||||||
tree: Tree::example(),
|
tree: Tree::demo(),
|
||||||
box_painting: Default::default(),
|
box_painting: Default::default(),
|
||||||
painting: Default::default(),
|
painting: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExampleWindow {
|
impl DemoWindow {
|
||||||
pub fn ui(&mut self, ui: &mut Ui) {
|
pub fn ui(&mut self, ui: &mut Ui) {
|
||||||
ui.collapsing("About Egui", |ui| {
|
ui.collapsing("About Egui", |ui| {
|
||||||
ui.add(label!(
|
ui.add(label!(
|
||||||
|
@ -238,7 +235,7 @@ impl ExampleWindow {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.collapsing("Name clash example", |ui| {
|
ui.collapsing("Name clash demo", |ui| {
|
||||||
ui.label("\
|
ui.label("\
|
||||||
Widgets that store state require unique identifiers so we can track their state between frames. \
|
Widgets that store state require unique identifiers so we can track their state between frames. \
|
||||||
Identifiers are normally derived from the titles of the widget.");
|
Identifiers are normally derived from the titles of the widget.");
|
||||||
|
@ -466,13 +463,13 @@ use crate::layout::*;
|
||||||
|
|
||||||
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "with_serde", serde(default))]
|
#[cfg_attr(feature = "with_serde", serde(default))]
|
||||||
struct LayoutExample {
|
struct LayoutDemo {
|
||||||
dir: Direction,
|
dir: Direction,
|
||||||
align: Option<Align>, // None == jusitifed
|
align: Option<Align>, // None == jusitifed
|
||||||
reversed: bool,
|
reversed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LayoutExample {
|
impl Default for LayoutDemo {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
dir: Direction::Vertical,
|
dir: Direction::Vertical,
|
||||||
|
@ -482,7 +479,7 @@ impl Default for LayoutExample {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutExample {
|
impl LayoutDemo {
|
||||||
pub fn ui(&mut self, ui: &mut Ui) {
|
pub fn ui(&mut self, ui: &mut Ui) {
|
||||||
Resize::default()
|
Resize::default()
|
||||||
.default_size([200.0, 100.0])
|
.default_size([200.0, 100.0])
|
||||||
|
@ -555,7 +552,7 @@ enum Action {
|
||||||
struct Tree(Vec<Tree>);
|
struct Tree(Vec<Tree>);
|
||||||
|
|
||||||
impl Tree {
|
impl Tree {
|
||||||
pub fn example() -> Self {
|
pub fn demo() -> Self {
|
||||||
Self(vec![
|
Self(vec![
|
||||||
Tree(vec![Tree::default(); 4]),
|
Tree(vec![Tree::default(); 4]),
|
||||||
Tree(vec![Tree(vec![Tree::default(); 2]); 3]),
|
Tree(vec![Tree(vec![Tree::default(); 2]); 3]),
|
|
@ -28,7 +28,7 @@ pub struct RawInput {
|
||||||
/// Time in seconds. Relative to whatever. Used for animation.
|
/// Time in seconds. Relative to whatever. Used for animation.
|
||||||
pub time: f64,
|
pub time: f64,
|
||||||
|
|
||||||
/// Local time. Only used for the clock in the example app.
|
/// Local time. Only used for the clock in the demo app.
|
||||||
pub seconds_since_midnight: Option<f64>,
|
pub seconds_since_midnight: Option<f64>,
|
||||||
|
|
||||||
/// In-order events received this frame
|
/// In-order events received this frame
|
||||||
|
@ -78,7 +78,7 @@ pub struct InputState {
|
||||||
/// Can be used to fast-forward to next frame for instance feedback. hacky.
|
/// Can be used to fast-forward to next frame for instance feedback. hacky.
|
||||||
pub predicted_dt: f32,
|
pub predicted_dt: f32,
|
||||||
|
|
||||||
/// Local time. Only used for the clock in the example app.
|
/// Local time. Only used for the clock in the demo app.
|
||||||
pub seconds_since_midnight: Option<f64>,
|
pub seconds_since_midnight: Option<f64>,
|
||||||
|
|
||||||
/// In-order events received this frame
|
/// In-order events received this frame
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
pub mod containers;
|
pub mod containers;
|
||||||
mod context;
|
mod context;
|
||||||
pub mod examples;
|
pub mod demos;
|
||||||
mod id;
|
mod id;
|
||||||
mod input;
|
mod input;
|
||||||
mod introspection;
|
mod introspection;
|
||||||
|
@ -42,7 +42,7 @@ pub mod widgets;
|
||||||
pub use {
|
pub use {
|
||||||
containers::*,
|
containers::*,
|
||||||
context::Context,
|
context::Context,
|
||||||
examples::ExampleApp,
|
demos::DemoApp,
|
||||||
id::Id,
|
id::Id,
|
||||||
input::*,
|
input::*,
|
||||||
layers::*,
|
layers::*,
|
||||||
|
|
|
@ -216,7 +216,7 @@ pub fn init_clipboard() -> Option<ClipboardContext> {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Time of day as seconds since midnight. Used for clock in example app.
|
/// Time of day as seconds since midnight. Used for clock in demo app.
|
||||||
pub fn local_time_of_day() -> f64 {
|
pub fn local_time_of_day() -> f64 {
|
||||||
use chrono::Timelike;
|
use chrono::Timelike;
|
||||||
let time = chrono::Local::now().time();
|
let time = chrono::Local::now().time();
|
||||||
|
|
|
@ -6,8 +6,6 @@ license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = { path = "../egui", features = ["with_serde"] }
|
egui = { git = "https://github.com/emilk/emigui" }
|
||||||
egui_glium = { path = "../egui_glium" }
|
egui_glium = { git = "https://github.com/emilk/emigui" }
|
||||||
glium = "0.27"
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
|
||||||
|
|
|
@ -1,70 +1,34 @@
|
||||||
#![deny(warnings)]
|
|
||||||
#![warn(clippy::all)]
|
|
||||||
|
|
||||||
use egui_glium::{persistence::Persistence, RunMode, Runner};
|
use egui_glium::{persistence::Persistence, RunMode, Runner};
|
||||||
|
|
||||||
const APP_KEY: &str = "app";
|
const APP_KEY: &str = "app";
|
||||||
|
|
||||||
|
/// We dervive Deserialize/Serialize so we can persist app state on shutdown.
|
||||||
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
||||||
struct MyApp {
|
struct MyApp {
|
||||||
egui_example_app: egui::ExampleApp,
|
counter: u64,
|
||||||
frames_painted: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl egui_glium::App for MyApp {
|
impl egui_glium::App for MyApp {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui, runner: &mut Runner) {
|
/// This function will be called whenever the Ui needs to be shown,
|
||||||
self.egui_example_app.ui(ui, "");
|
/// which may be many times per second.
|
||||||
|
fn ui(&mut self, ui: &mut egui::Ui, _: &mut Runner) {
|
||||||
use egui::*;
|
if ui.button("Increment").clicked {
|
||||||
let mut ui = ui.centered_column(ui.available().width().min(480.0));
|
self.counter += 1;
|
||||||
ui.set_layout(Layout::vertical(Align::Min));
|
|
||||||
ui.add(label!("Egui inside of Glium").text_style(TextStyle::Heading));
|
|
||||||
if ui.add(Button::new("Quit")).clicked {
|
|
||||||
runner.quit();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if ui.button("Reset").clicked {
|
||||||
ui.add(
|
self.counter = 0;
|
||||||
label!(
|
|
||||||
"CPU usage: {:.2} ms / frame (excludes painting)",
|
|
||||||
1e3 * runner.cpu_time()
|
|
||||||
)
|
|
||||||
.text_style(TextStyle::Monospace),
|
|
||||||
);
|
|
||||||
|
|
||||||
ui.separator();
|
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
let mut run_mode = runner.run_mode();
|
|
||||||
ui.label("Run mode:");
|
|
||||||
ui.radio_value("Continuous", &mut run_mode, RunMode::Continuous)
|
|
||||||
.tooltip_text("Repaint everything each frame");
|
|
||||||
ui.radio_value("Reactive", &mut run_mode, RunMode::Reactive)
|
|
||||||
.tooltip_text("Repaint when there are animations or input (e.g. mouse movement)");
|
|
||||||
runner.set_run_mode(run_mode);
|
|
||||||
});
|
|
||||||
|
|
||||||
if runner.run_mode() == RunMode::Continuous {
|
|
||||||
ui.add(
|
|
||||||
label!("Repainting the UI each frame. FPS: {:.1}", runner.fps())
|
|
||||||
.text_style(TextStyle::Monospace),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ui.label("Only running UI code when there are animations or input");
|
|
||||||
}
|
}
|
||||||
|
ui.label(format!("Counter: {}", self.counter));
|
||||||
self.frames_painted += 1;
|
|
||||||
ui.label(format!("Total frames painted: {}", self.frames_painted));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_exit(&mut self, persistence: &mut Persistence) {
|
fn on_exit(&mut self, persistence: &mut Persistence) {
|
||||||
persistence.set_value(APP_KEY, self);
|
persistence.set_value(APP_KEY, self); // Save app state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let title = "Egui glium example";
|
let title = "My Egui Window";
|
||||||
let persistence = Persistence::from_path(".egui_example_glium.json".into());
|
let persistence = Persistence::from_path(".egui_example_glium.json".into()); // Where to persist app state
|
||||||
let app: MyApp = persistence.get_value(APP_KEY).unwrap_or_default();
|
let app: MyApp = persistence.get_value(APP_KEY).unwrap_or_default(); // Restore `MyApp` from file, or create new `MyApp`.
|
||||||
egui_glium::run(title, RunMode::Reactive, persistence, app);
|
egui_glium::run(title, RunMode::Reactive, persistence, app);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue