Skip to content

Commit

Permalink
Minor cleanup following #999
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 28, 2021
1 parent f919b0c commit cda4c8b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
6 changes: 4 additions & 2 deletions egui_glium/src/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub struct Painter {
/// Index is the same as in [`egui::TextureId::User`].
user_textures: HashMap<u64, Rc<SrgbTexture2d>>,

// TODO: 128-bit texture space?
next_native_tex_id: u64,
#[cfg(feature = "epi")]
next_native_tex_id: u64, // TODO: 128-bit texture space?
}

impl Painter {
Expand Down Expand Up @@ -57,6 +57,7 @@ impl Painter {
egui_texture: None,
egui_texture_version: None,
user_textures: Default::default(),
#[cfg(feature = "epi")]
next_native_tex_id: 1 << 32,
}
}
Expand Down Expand Up @@ -222,6 +223,7 @@ impl Painter {

// ------------------------------------------------------------------------

#[cfg(feature = "epi")]
pub fn set_texture(
&mut self,
facade: &dyn glium::backend::Facade,
Expand Down
2 changes: 0 additions & 2 deletions egui_glow/src/misc_util.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![allow(unsafe_code)]
use glow::HasContext;
use std::option::Option::Some;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::JsValue;

pub(crate) fn srgbtexture2d(
gl: &glow::Context,
Expand Down
8 changes: 6 additions & 2 deletions egui_glow/src/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ pub struct Painter {

/// Index is the same as in [`egui::TextureId::User`].
user_textures: HashMap<u64, glow::Texture>,
// TODO: 128-bit texture space?
next_native_tex_id: u64,

#[cfg(feature = "epi")]
next_native_tex_id: u64, // TODO: 128-bit texture space?

/// Stores outdated OpenGL textures that are yet to be deleted
textures_to_destroy: Vec<glow::Texture>,

Expand Down Expand Up @@ -192,6 +194,7 @@ impl Painter {
vertex_buffer,
element_array_buffer,
user_textures: Default::default(),
#[cfg(feature = "epi")]
next_native_tex_id: 1 << 32,
textures_to_destroy: Vec::new(),
destroyed: false,
Expand Down Expand Up @@ -386,6 +389,7 @@ impl Painter {

// ------------------------------------------------------------------------

#[cfg(feature = "epi")]
pub fn set_texture(&mut self, gl: &glow::Context, tex_id: u64, image: &epi::Image) {
self.assert_not_destroyed();

Expand Down
3 changes: 1 addition & 2 deletions egui_web/src/webgl1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ pub struct WebGlPainter {
/// Index is the same as in [`egui::TextureId::User`].
user_textures: HashMap<u64, WebGlTexture>,

// TODO: 128-bit texture space?
next_native_tex_id: u64,
next_native_tex_id: u64, // TODO: 128-bit texture space?
}

impl WebGlPainter {
Expand Down
3 changes: 1 addition & 2 deletions egui_web/src/webgl2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ pub struct WebGl2Painter {
/// Index is the same as in [`egui::TextureId::User`].
user_textures: HashMap<u64, WebGlTexture>,

// TODO: 128-bit texture space?
next_native_tex_id: u64,
next_native_tex_id: u64, // TODO: 128-bit texture space?
}

impl WebGl2Painter {
Expand Down
5 changes: 2 additions & 3 deletions epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,10 @@ pub trait NativeTexture {
/// The native texture type.
type Texture;

/// Bind native texture to egui texture
/// Bind native texture to an egui texture id.
fn register_native_texture(&mut self, native: Self::Texture) -> egui::TextureId;

/// Change id's actual pointing texture
/// only for user texture
/// Change what texture the given id refers to.
fn replace_native_texture(&mut self, id: egui::TextureId, replacing: Self::Texture);
}

Expand Down

0 comments on commit cda4c8b

Please sign in to comment.