mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Split example app from emigui_wasm
This commit is contained in:
@@ -39,26 +39,24 @@
|
||||
// hack when deploying over HTTP.
|
||||
delete WebAssembly.instantiateStreaming;
|
||||
</script>
|
||||
|
||||
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||
<script src="emigui_wasm.js"></script>
|
||||
<script src="example.js"></script>
|
||||
|
||||
<script>
|
||||
// we'll defer our execution until the wasm is ready to go
|
||||
function wasm_loaded() {
|
||||
console.log("wasm loaded");
|
||||
initialize();
|
||||
}
|
||||
// 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
|
||||
wasm_bindgen("./emigui_wasm_bg.wasm")
|
||||
.then(wasm_loaded)["catch"](console.error);
|
||||
wasm_bindgen("./example_bg.wasm")
|
||||
.then(on_wasm_loaded)["catch"](console.error);
|
||||
// ----------------------------------------------------------------------------
|
||||
var g_webgl_painter = null;
|
||||
var g_wasm_app = null;
|
||||
|
||||
function paint_gui(canvas, input) {
|
||||
if (g_webgl_painter === null) {
|
||||
g_webgl_painter = wasm_bindgen.new_webgl_gui("canvas", pixels_per_point());
|
||||
if (g_wasm_app === null) {
|
||||
g_wasm_app = wasm_bindgen.new_webgl_gui("canvas", pixels_per_point());
|
||||
}
|
||||
wasm_bindgen.run_gui(g_webgl_painter, JSON.stringify(input));
|
||||
wasm_bindgen.run_gui(g_wasm_app, JSON.stringify(input));
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
var g_mouse_pos = { x: -1000.0, y: -1000.0 };
|
||||
@@ -93,7 +91,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
function on_wasm_loaded() {
|
||||
console.log("window.devicePixelRatio: " + window.devicePixelRatio);
|
||||
var canvas = document.getElementById("canvas");
|
||||
var repaint = function() {
|
||||
|
||||
Reference in New Issue
Block a user