Combine demo_glium and demo_web into one egui_demo crate

This commit is contained in:
Emil Ernerfeldt
2020-12-19 21:38:44 +01:00
parent fb941cf618
commit d0f6954900
19 changed files with 93 additions and 111 deletions
+23
View File
@@ -0,0 +1,23 @@
[package]
name = "egui_demo"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
egui = { path = "../egui", features = ["serde", "serde_json"] }
serde = { version = "1", features = ["derive"] }
# For compiling natively:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
egui_glium = { path = "../egui_glium" }
# For compiling to web:
[target.'cfg(target_arch = "wasm32")'.dependencies]
egui_web = { path = "../egui_web" }
js-sys = "0.3"
wasm-bindgen = "0.2"
+18
View File
@@ -0,0 +1,18 @@
#![forbid(unsafe_code)]
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
#![warn(clippy::all)]
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
/// This is the entry-point for all the web-assembly.
/// This is called once from the HTML.
/// It loads the app, installs some callbacks, then returns.
/// You can add more callbacks like this if you want to call in to your code.
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
let app = egui::DemoApp::default();
egui_web::start(canvas_id, Box::new(app))?;
Ok(())
}
+9
View File
@@ -0,0 +1,9 @@
#![forbid(unsafe_code)]
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
#![warn(clippy::all)]
// When compiling natively:
fn main() {
let app = egui::DemoApp::default();
egui_glium::run(Box::new(app));
}