1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Clean up egui_web code a bit

This commit is contained in:
Emil Ernerfeldt
2021-04-01 22:11:29 +02:00
parent d7f9e2246c
commit 1068750bbc
3 changed files with 19 additions and 18 deletions

View File

@@ -192,6 +192,7 @@ impl WebGl2Painter {
}
}
}
pub fn register_webgl_texture(&mut self, texture: WebGlTexture) -> egui::TextureId {
let id = self.alloc_user_texture_index();
if let Some(Some(user_texture)) = self.user_textures.get_mut(id) {
@@ -203,20 +204,18 @@ impl WebGl2Painter {
}
egui::TextureId::User(id as u64)
}
fn paint_mesh(&self, mesh: &egui::epaint::Mesh16) -> Result<(), JsValue> {
debug_assert!(mesh.is_valid());
let mut positions: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());
let mut tex_coords: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());
let mut colors: Vec<u8> = Vec::with_capacity(4 * mesh.vertices.len());
for v in &mesh.vertices {
positions.push(v.pos.x);
positions.push(v.pos.y);
tex_coords.push(v.uv.x);
tex_coords.push(v.uv.y);
}
let mut colors: Vec<u8> = Vec::with_capacity(4 * mesh.vertices.len());
for v in &mesh.vertices {
colors.push(v.color[0]);
colors.push(v.color[1]);
colors.push(v.color[2]);