I'm trying to integrate egui into a wasm-bindgen app that also needs to draw some other geometry. Basically my app tries to do the job of your AppRunner
class also using egui_web
, but also rendering other things, and doing other things with the input events, etc.
If I use something like SpectorJS I can debug the draw call and see that drawElements is called with the font atlas texture bound to sampler 0, which is why the lines look strange: I think it's drawing them with the texture atlas bound? It is also likely the same thing that is preventing the actual text from showing. I wonder if you know what could be wrong, of if there's anything I'm missing?
let mut backend = egui_web::WebBackend::new("mycanvas").expect("Failed to make a web backend for egui");
let mut web_input: WebInput = Default::default();
ctx.clear_color(0.1, 0.1, 0.2, 1.0);
ctx.clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
let raw_input = web_input.new_frame();
let ui = backend.begin_frame(raw_input);
let mut s = String::from("test");
let mut value = 0.0;
egui::Window::new("Debug").show(&ui.ctx(), |ui| {
ui.label(format!("Hello, world {}", 123));
if ui.button("Save").clicked {
log::info!("Save!");
}
ui.text_edit(&mut s);
ui.add(egui::Slider::f32(&mut value, 0.0..=1.0).text("float"));
});
let (output, paint_jobs) = backend.end_frame().unwrap();
backend.paint(paint_jobs).expect("Failed to paint!");
ctx.viewport(
0,
0,
canvas_width_on_screen as i32,
canvas_height_on_screen as i32,
);
cube.render(
&context,
(js_sys::Date::now() - start_millis) as f32,
curr_state.canvas_width,
curr_state.canvas_height,
);