mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
add texture registering function
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use wasm_bindgen::prelude::JsValue;
|
||||
use web_sys::WebGlTexture;
|
||||
|
||||
pub trait Painter {
|
||||
fn as_tex_allocator(&mut self) -> &mut dyn epi::TextureAllocator;
|
||||
|
||||
@@ -4,10 +4,7 @@ use {
|
||||
web_sys::{WebGlBuffer, WebGlProgram, WebGlRenderingContext, WebGlShader, WebGlTexture},
|
||||
};
|
||||
|
||||
use egui::{
|
||||
emath::{clamp, vec2},
|
||||
epaint::{Color32, Texture},
|
||||
};
|
||||
use egui::{emath::{clamp, vec2}, epaint::{Color32, Texture}};
|
||||
|
||||
type Gl = WebGlRenderingContext;
|
||||
|
||||
@@ -190,7 +187,13 @@ 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());
|
||||
|
||||
|
||||
@@ -192,7 +192,13 @@ 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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user