glow-vs-web cleanup following https://github.com/emilk/egui/pull/868
This commit is contained in:
parent
804722a1ba
commit
c71090473b
6 changed files with 15 additions and 7 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -936,6 +936,8 @@ dependencies = [
|
||||||
"glutin",
|
"glutin",
|
||||||
"image",
|
"image",
|
||||||
"memoffset",
|
"memoffset",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -943,6 +945,7 @@ name = "egui_web"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"egui",
|
"egui",
|
||||||
|
"egui_glow",
|
||||||
"epi",
|
"epi",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"ron",
|
"ron",
|
||||||
|
|
|
@ -30,7 +30,7 @@ epi = { version = "0.15.0", path = "../epi" }
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
egui-winit = { version = "0.15.0", path = "../egui-winit", default-features = false }
|
egui-winit = { version = "0.15.0", path = "../egui-winit", default-features = false }
|
||||||
egui_glium = { version = "0.15.0", path = "../egui_glium", default-features = false, features = ["clipboard", "epi", "links"], optional = true }
|
egui_glium = { version = "0.15.0", path = "../egui_glium", default-features = false, features = ["clipboard", "epi", "links"], optional = true }
|
||||||
egui_glow = { version = "0.15.0", path = "../egui_glow", default-features = false, features = ["clipboard", "epi", "links"], optional = true }
|
egui_glow = { version = "0.15.0", path = "../egui_glow", default-features = false, features = ["clipboard", "epi", "links", "winit"], optional = true }
|
||||||
|
|
||||||
# web:
|
# web:
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
|
|
@ -98,7 +98,9 @@ mod shader_version;
|
||||||
mod vao_emulate;
|
mod vao_emulate;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
#[cfg(feature = "egui_winit")]
|
||||||
pub use egui_winit;
|
pub use egui_winit;
|
||||||
|
|
||||||
#[cfg(all(feature = "epi", feature = "winit"))]
|
#[cfg(all(feature = "epi", feature = "winit"))]
|
||||||
pub use epi_backend::{run, NativeOptions};
|
pub use epi_backend::{run, NativeOptions};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use egui::{
|
use egui::{
|
||||||
emath::Rect,
|
emath::Rect,
|
||||||
epaint::{Color32, Mesh, Vertex},
|
epaint::{Color32, Mesh, Vertex},
|
||||||
TextureId,
|
|
||||||
};
|
};
|
||||||
pub use glow::Context;
|
pub use glow::Context;
|
||||||
|
|
||||||
|
@ -540,7 +539,7 @@ impl Painter {
|
||||||
debug_assert!(!self.destroyed, "the egui glow has already been destroyed!");
|
debug_assert!(!self.destroyed, "the egui glow has already been destroyed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ported from egui_web
|
|
||||||
pub fn clear(gl: &glow::Context, dimension: [u32; 2], clear_color: egui::Rgba) {
|
pub fn clear(gl: &glow::Context, dimension: [u32; 2], clear_color: egui::Rgba) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gl.disable(glow::SCISSOR_TEST);
|
gl.disable(glow::SCISSOR_TEST);
|
||||||
|
@ -557,6 +556,7 @@ pub fn clear(gl: &glow::Context, dimension: [u32; 2], clear_color: egui::Rgba) {
|
||||||
gl.clear(glow::COLOR_BUFFER_BIT);
|
gl.clear(glow::COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Painter {
|
impl Drop for Painter {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
|
@ -566,6 +566,7 @@ impl Drop for Painter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "epi")]
|
||||||
impl epi::TextureAllocator for Painter {
|
impl epi::TextureAllocator for Painter {
|
||||||
fn alloc_srgba_premultiplied(
|
fn alloc_srgba_premultiplied(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -582,14 +583,15 @@ impl epi::TextureAllocator for Painter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "epi")]
|
||||||
impl epi::NativeTexture for Painter {
|
impl epi::NativeTexture for Painter {
|
||||||
type Texture = glow::Texture;
|
type Texture = glow::Texture;
|
||||||
|
|
||||||
fn register_native_texture(&mut self, native: Self::Texture) -> TextureId {
|
fn register_native_texture(&mut self, native: Self::Texture) -> egui::TextureId {
|
||||||
self.register_glow_texture(native)
|
self.register_glow_texture(native)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replace_native_texture(&mut self, id: TextureId, replacing: Self::Texture) {
|
fn replace_native_texture(&mut self, id: egui::TextureId, replacing: Self::Texture) {
|
||||||
if let egui::TextureId::User(id) = id {
|
if let egui::TextureId::User(id) = id {
|
||||||
if let Some(Some(user_texture)) = self.user_textures.get_mut(id as usize) {
|
if let Some(Some(user_texture)) = self.user_textures.get_mut(id as usize) {
|
||||||
*user_texture = UserTexture {
|
*user_texture = UserTexture {
|
||||||
|
|
|
@ -43,9 +43,10 @@ default = ["default_fonts"]
|
||||||
# If set, egui will use `include_bytes!` to bundle some fonts.
|
# If set, egui will use `include_bytes!` to bundle some fonts.
|
||||||
# If you plan on specifying your own fonts you may disable this feature.
|
# If you plan on specifying your own fonts you may disable this feature.
|
||||||
default_fonts = ["egui/default_fonts"]
|
default_fonts = ["egui/default_fonts"]
|
||||||
|
# Use glow as the renderer
|
||||||
|
glow = ["egui_glow", "egui_glow/epi"]
|
||||||
persistence = ["egui/persistence", "ron", "serde"]
|
persistence = ["egui/persistence", "ron", "serde"]
|
||||||
screen_reader = ["tts"] # experimental
|
screen_reader = ["tts"] # experimental
|
||||||
glow =["egui_glow","egui_glow/epi"]
|
|
||||||
|
|
||||||
[dependencies.web-sys]
|
[dependencies.web-sys]
|
||||||
version = "0.3.52"
|
version = "0.3.52"
|
||||||
|
|
Loading…
Reference in a new issue