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

Add functions to register textures in egui_web and egui_glium (#226)

* add texture registering function

* fmt

* Revert "add texture registering function"

This reverts commit f9b4db12

* make get_texture public to get render target owned by Painter .

* revert egui_web painter.rs change
This commit is contained in:
triangle drawer
2021-03-13 20:41:51 +09:00
committed by GitHub
parent 958aea922f
commit b1883d5d48
3 changed files with 42 additions and 7 deletions

View File

@@ -136,8 +136,7 @@ impl WebGlPainter {
}
}
}
fn get_texture(&self, texture_id: egui::TextureId) -> Option<&WebGlTexture> {
pub fn get_texture(&self, texture_id: egui::TextureId) -> Option<&WebGlTexture> {
match texture_id {
egui::TextureId::Egui => Some(&self.egui_texture),
egui::TextureId::User(id) => self
@@ -190,7 +189,17 @@ impl WebGlPainter {
}
}
}
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) {
*user_texture = UserTexture {
size: (0, 0),
pixels: vec![],
gl_texture: Some(texture),
}
}
egui::TextureId::User(id as u64)
}
fn paint_mesh(&self, mesh: &egui::epaint::Mesh16) -> Result<(), JsValue> {
debug_assert!(mesh.is_valid());

View File

@@ -139,7 +139,7 @@ impl WebGl2Painter {
}
}
fn get_texture(&self, texture_id: egui::TextureId) -> Option<&WebGlTexture> {
pub fn get_texture(&self, texture_id: egui::TextureId) -> Option<&WebGlTexture> {
match texture_id {
egui::TextureId::Egui => Some(&self.egui_texture),
egui::TextureId::User(id) => self
@@ -192,7 +192,17 @@ 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) {
*user_texture = UserTexture {
size: (0, 0),
pixels: vec![],
gl_texture: Some(texture),
}
}
egui::TextureId::User(id as u64)
}
fn paint_mesh(&self, mesh: &egui::epaint::Mesh16) -> Result<(), JsValue> {
debug_assert!(mesh.is_valid());