
* egui_web: always use the glow painter, and remove the old WebGL code. * Clean up the WebPainter trait * Clarify WebGL1 warning text in color test The glow painter became standard in egui 0.17, and I've heard no complaints! So let's simplify and go all in on glow. Part of https://github.com/emilk/egui/issues/1198
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
use wasm_bindgen::prelude::JsValue;
|
|
|
|
/// What is needed to paint egui.
|
|
pub trait WebPainter {
|
|
fn name(&self) -> &'static str;
|
|
|
|
/// Max size of one side of a texture.
|
|
fn max_texture_side(&self) -> usize;
|
|
|
|
/// id of the canvas html element containing the rendering
|
|
fn canvas_id(&self) -> &str;
|
|
|
|
fn set_texture(&mut self, tex_id: egui::TextureId, delta: &egui::epaint::ImageDelta);
|
|
|
|
fn free_texture(&mut self, tex_id: egui::TextureId);
|
|
|
|
fn clear(&mut self, clear_color: egui::Rgba);
|
|
|
|
fn paint_meshes(
|
|
&mut self,
|
|
clipped_meshes: Vec<egui::ClippedMesh>,
|
|
pixels_per_point: f32,
|
|
) -> Result<(), JsValue>;
|
|
|
|
fn paint_and_update_textures(
|
|
&mut self,
|
|
clipped_meshes: Vec<egui::ClippedMesh>,
|
|
pixels_per_point: f32,
|
|
textures_delta: &egui::TexturesDelta,
|
|
) -> Result<(), JsValue> {
|
|
for (id, image_delta) in &textures_delta.set {
|
|
self.set_texture(*id, image_delta);
|
|
}
|
|
|
|
self.paint_meshes(clipped_meshes, pixels_per_point)?;
|
|
|
|
for &id in &textures_delta.free {
|
|
self.free_texture(id);
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|