Combine demo_glium and demo_web into one egui_demo crate
This commit is contained in:
parent
fb941cf618
commit
d0f6954900
19 changed files with 93 additions and 111 deletions
6
.github/workflows/rust.yml
vendored
6
.github/workflows/rust.yml
vendored
|
@ -20,8 +20,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
|
|
||||||
check_demo_web:
|
check_egui_demo_web:
|
||||||
name: Check demo_web
|
name: Check egui_demo (web)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
@ -34,7 +34,7 @@ jobs:
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
args: -p demo_web --target wasm32-unknown-unknown
|
args: -p egui_demo --lib --target wasm32-unknown-unknown
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test Suite
|
name: Test Suite
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
**/target
|
**/target
|
||||||
/.*.json
|
/.*.json
|
||||||
/.vscode
|
/.vscode
|
||||||
|
/media/*
|
||||||
|
|
33
Cargo.lock
generated
33
Cargo.lock
generated
|
@ -521,27 +521,6 @@ dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "demo_glium"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"egui",
|
|
||||||
"egui_glium",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "demo_web"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"egui",
|
|
||||||
"egui_web",
|
|
||||||
"js-sys",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derivative"
|
name = "derivative"
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
|
@ -607,6 +586,18 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "egui_demo"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"egui",
|
||||||
|
"egui_glium",
|
||||||
|
"egui_web",
|
||||||
|
"js-sys",
|
||||||
|
"serde",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui_glium"
|
name = "egui_glium"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"demo_glium",
|
"egui_demo",
|
||||||
"demo_web",
|
|
||||||
"egui_glium",
|
"egui_glium",
|
||||||
"egui_web",
|
"egui_web",
|
||||||
"egui",
|
"egui",
|
||||||
"example_web",
|
"example_web",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
egui = { path = 'egui' }
|
egui = { path = 'egui' }
|
||||||
egui_glium = { path = 'egui_glium' }
|
egui_glium = { path = 'egui_glium' }
|
||||||
|
|
4
build_demo_native.sh
Executable file
4
build_demo_native.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
cargo run --bin egui_demo --release
|
|
@ -1,30 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Pre-requisites:
|
CRATE_NAME="egui_demo"
|
||||||
rustup target add wasm32-unknown-unknown
|
|
||||||
if ! wasm-bindgen --version; then
|
|
||||||
cargo clean
|
|
||||||
cargo install -f wasm-bindgen-cli
|
|
||||||
cargo update
|
|
||||||
fi
|
|
||||||
|
|
||||||
# BUILD=debug
|
|
||||||
BUILD=release
|
|
||||||
|
|
||||||
export RUSTFLAGS=--cfg=web_sys_unstable_apis # required for the clipboard API
|
export RUSTFLAGS=--cfg=web_sys_unstable_apis # required for the clipboard API
|
||||||
|
|
||||||
# Clear output from old stuff:
|
# Clear output from old stuff:
|
||||||
rm -rf docs/demo_web.wasm
|
rm -rf docs/$CRATE_NAME.wasm
|
||||||
|
|
||||||
echo "Build rust:"
|
echo "Building rust…"
|
||||||
# cargo build -p demo_web --target wasm32-unknown-unknown
|
BUILD=release
|
||||||
cargo build --release -p demo_web --target wasm32-unknown-unknown
|
cargo build --release -p $CRATE_NAME --lib --target wasm32-unknown-unknown
|
||||||
|
|
||||||
echo "Generate JS bindings for wasm:"
|
echo "Generating JS bindings for wasm…"
|
||||||
FOLDER_NAME=${PWD##*/}
|
TARGET_NAME="$CRATE_NAME.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
|
||||||
|
|
||||||
|
echo "Finished: docs/$CRATE_NAME.wasm"
|
||||||
|
|
||||||
open http://localhost:8888/index.html
|
open http://localhost:8888/index.html
|
||||||
|
|
|
@ -1,30 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Pre-requisites:
|
CRATE_NAME="example_web"
|
||||||
rustup target add wasm32-unknown-unknown
|
|
||||||
if ! wasm-bindgen --version; then
|
|
||||||
cargo clean
|
|
||||||
cargo install -f wasm-bindgen-cli
|
|
||||||
cargo update
|
|
||||||
fi
|
|
||||||
|
|
||||||
# BUILD=debug
|
|
||||||
BUILD=release
|
|
||||||
|
|
||||||
export RUSTFLAGS=--cfg=web_sys_unstable_apis # required for the clipboard API
|
export RUSTFLAGS=--cfg=web_sys_unstable_apis # required for the clipboard API
|
||||||
|
|
||||||
# Clear output from old stuff:
|
# Clear output from old stuff:
|
||||||
rm -rf docs/example_web.wasm
|
rm -rf docs/$CRATE_NAME.wasm
|
||||||
|
|
||||||
echo "Build rust:"
|
echo "Building rust…"
|
||||||
# cargo build -p example_web --target wasm32-unknown-unknown
|
BUILD=release
|
||||||
cargo build --release -p example_web --target wasm32-unknown-unknown
|
cargo build --release -p $CRATE_NAME --lib --target wasm32-unknown-unknown
|
||||||
|
|
||||||
echo "Generate JS bindings for wasm:"
|
echo "Generating JS bindings for wasm…"
|
||||||
FOLDER_NAME=${PWD##*/}
|
TARGET_NAME="$CRATE_NAME.wasm"
|
||||||
TARGET_NAME="example_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
|
||||||
|
|
||||||
|
echo "Finished: docs/$CRATE_NAME.wasm"
|
||||||
|
|
||||||
open http://localhost:8888/example.html
|
open http://localhost:8888/example.html
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
cargo run --bin demo_glium --release
|
|
8
check.sh
8
check.sh
|
@ -9,10 +9,10 @@ CARGO_INCREMENTAL=0 cargo clippy --workspace --all-targets --all-features -- -D
|
||||||
cargo test --workspace --all-targets --all-features
|
cargo test --workspace --all-targets --all-features
|
||||||
cargo test --workspace --doc
|
cargo test --workspace --doc
|
||||||
|
|
||||||
cargo check -p egui --target wasm32-unknown-unknown
|
cargo check -p egui --lib --target wasm32-unknown-unknown
|
||||||
cargo check -p egui_web --target wasm32-unknown-unknown
|
cargo check -p egui_web --lib --target wasm32-unknown-unknown
|
||||||
cargo check -p demo_web --target wasm32-unknown-unknown
|
cargo check -p egui_demo --lib --target wasm32-unknown-unknown
|
||||||
cargo check -p example_web --target wasm32-unknown-unknown
|
cargo check -p example_web --lib --target wasm32-unknown-unknown
|
||||||
|
|
||||||
# For finding bloat:
|
# For finding bloat:
|
||||||
# cargo bloat --release --bin demo_glium -n 200 | rg egui
|
# cargo bloat --release --bin demo_glium -n 200 | rg egui
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[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 = { path = "../egui", features = ["serde", "serde_json"] }
|
|
||||||
egui_glium = { path = "../egui_glium" }
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
|
@ -213,35 +213,35 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
||||||
return real;
|
return real;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_24(arg0, arg1) {
|
function __wbg_adapter_24(arg0, arg1) {
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf85506f45f4e8b16(arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h81f03ee2d784e177(arg0, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_27(arg0, arg1, arg2) {
|
function __wbg_adapter_27(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h047d08be48ab6c09(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h16ce614a5c125c56(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_30(arg0, arg1, arg2) {
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h047d08be48ab6c09(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h16ce614a5c125c56(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_33(arg0, arg1, arg2) {
|
function __wbg_adapter_33(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h047d08be48ab6c09(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h16ce614a5c125c56(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_36(arg0, arg1) {
|
function __wbg_adapter_36(arg0, arg1) {
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf802d845e8b4a07b(arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hcb627f1d4e0d7728(arg0, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_39(arg0, arg1, arg2) {
|
function __wbg_adapter_39(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h047d08be48ab6c09(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h16ce614a5c125c56(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_42(arg0, arg1, arg2) {
|
function __wbg_adapter_42(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h047d08be48ab6c09(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h16ce614a5c125c56(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_45(arg0, arg1, arg2) {
|
function __wbg_adapter_45(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf01ebeadb2908509(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h49f53e48165122c2(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -604,8 +604,8 @@ async function init(input) {
|
||||||
imports.wbg.__wbg_viewport_54305c74f5668b33 = function(arg0, arg1, arg2, arg3, arg4) {
|
imports.wbg.__wbg_viewport_54305c74f5668b33 = function(arg0, arg1, arg2, arg3, arg4) {
|
||||||
getObject(arg0).viewport(arg1, arg2, arg3, arg4);
|
getObject(arg0).viewport(arg1, arg2, arg3, arg4);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbg_log_f2e13ca55da8bad3 = function(arg0) {
|
imports.wbg.__wbg_error_e325755affc8634b = function(arg0) {
|
||||||
console.log(getObject(arg0));
|
console.error(getObject(arg0));
|
||||||
};
|
};
|
||||||
imports.wbg.__wbg_warn_9e92ccdc67085e1b = function(arg0) {
|
imports.wbg.__wbg_warn_9e92ccdc67085e1b = function(arg0) {
|
||||||
console.warn(getObject(arg0));
|
console.warn(getObject(arg0));
|
||||||
|
@ -795,35 +795,35 @@ async function init(input) {
|
||||||
var ret = wasm.memory;
|
var ret = wasm.memory;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper434 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper308 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_24);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_24);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper435 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper309 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_27);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_27);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper438 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper311 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_30);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_30);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper440 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper313 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_33);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_33);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper442 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper315 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_36);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_36);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper444 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper317 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_39);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_39);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper446 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper320 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 93, __wbg_adapter_42);
|
var ret = makeMutClosure(arg0, arg1, 57, __wbg_adapter_42);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper521 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper499 = function(arg0, arg1, arg2) {
|
||||||
var ret = makeMutClosure(arg0, arg1, 128, __wbg_adapter_45);
|
var ret = makeMutClosure(arg0, arg1, 128, __wbg_adapter_45);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
Binary file not shown.
|
@ -56,13 +56,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="demo_web.js"></script>
|
<script src="egui_demo.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("./demo_web_bg.wasm")
|
wasm_bindgen("./egui_demo_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,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "demo_web"
|
name = "egui_demo"
|
||||||
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"
|
||||||
|
@ -10,8 +10,14 @@ crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = { path = "../egui", features = ["serde", "serde_json"] }
|
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" }
|
egui_web = { path = "../egui_web" }
|
||||||
js-sys = "0.3"
|
js-sys = "0.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
||||||
serde_json = "1"
|
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
|
@ -2,12 +2,14 @@
|
||||||
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
/// This is the entry-point for all the web-assembly.
|
/// This is the entry-point for all the web-assembly.
|
||||||
/// This is called once from the HTML.
|
/// This is called once from the HTML.
|
||||||
/// It loads the app, installs some callbacks, then returns.
|
/// 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.
|
/// You can add more callbacks like this if you want to call in to your code.
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
||||||
let app = egui::DemoApp::default();
|
let app = egui::DemoApp::default();
|
|
@ -2,6 +2,7 @@
|
||||||
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
|
|
||||||
|
// When compiling natively:
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = egui::DemoApp::default();
|
let app = egui::DemoApp::default();
|
||||||
egui_glium::run(Box::new(app));
|
egui_glium::run(Box::new(app));
|
|
@ -7,6 +7,6 @@
|
||||||
|
|
||||||
This crates allows you to compile GUI code written with [Egui](https://crates.io/crates/egui) to [WASM](https://en.wikipedia.org/wiki/WebAssembly) to run on a web page.
|
This crates allows you to compile GUI code written with [Egui](https://crates.io/crates/egui) to [WASM](https://en.wikipedia.org/wiki/WebAssembly) to run on a web page.
|
||||||
|
|
||||||
Check out [docs/index.html](https://github.com/emilk/egui/blob/master/docs/index.html), [demo_web](https://github.com/emilk/egui/tree/master/demo_web) and [build_web.sh](https://github.com/emilk/egui/blob/master/build_web.sh) for examples of how to set it up.
|
Check out [docs/index.html](https://github.com/emilk/egui/blob/master/docs/index.html), [egui_demo](https://github.com/emilk/egui/tree/master/egui_demo) and [build_web.sh](https://github.com/emilk/egui/blob/master/build_web.sh) for examples of how to set it up.
|
||||||
|
|
||||||
To use `egui_web`, you need to set the `RUSTFLAGS=--cfg=web_sys_unstable_apis` flag.
|
To use `egui_web`, you need to set the `RUSTFLAGS=--cfg=web_sys_unstable_apis` flag.
|
||||||
|
|
3
example_web/README.md
Normal file
3
example_web/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# egui_web fetch example
|
||||||
|
|
||||||
|
This is an example of how to write a web-app which use the fetch API.
|
7
setup_web.sh
Executable file
7
setup_web.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Pre-requisites:
|
||||||
|
rustup target add wasm32-unknown-unknown
|
||||||
|
cargo install -f wasm-bindgen-cli
|
||||||
|
cargo update
|
Loading…
Reference in a new issue