Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating egui and egui_glow to 0.24 #419

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ cgmath = "0.18"
three-d-asset = {version = "0.6"}
thiserror = "1"
winit = {version = "0.28", optional = true}
egui = { version = "0.22", optional = true }
egui_glow = { version = "0.22", optional = true }
egui = { version = "0.24", optional = true }
egui_glow = { version = "0.24", optional = true }
getrandom = { version = "0.2", features = ["js"], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down Expand Up @@ -188,4 +188,4 @@ required-features = ["headless"]

[[example]]
name = "logo"
path = "examples/logo/src/main.rs"
path = "examples/logo/src/main.rs"
7 changes: 4 additions & 3 deletions src/core/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use std::collections::HashMap;
use std::rc::Rc;
use std::sync::Arc;
use std::sync::RwLock;

Expand All @@ -13,7 +14,7 @@ pub use crate::context::HasContext;
///
#[derive(Clone)]
pub struct Context {
context: Arc<crate::context::Context>,
context: Rc<crate::context::Context>,
pub(super) vao: crate::context::VertexArray,
/// A cache of programs to avoid recompiling a [Program] every frame.
pub programs: Arc<RwLock<HashMap<Vec<u8>, Program>>>,
Expand All @@ -26,7 +27,7 @@ impl Context {
/// Since the content in the [context](crate::context) module is just a re-export of [glow](https://crates.io/crates/glow),
/// you can also call this method with a reference counter to a glow context created using glow and not the re-export in [context](crate::context).
///
pub fn from_gl_context(context: Arc<crate::context::Context>) -> Result<Self, CoreError> {
pub fn from_gl_context(context: Rc<crate::context::Context>) -> Result<Self, CoreError> {
unsafe {
if !context.version().is_embedded {
// Enable seamless cube map textures - not available on OpenGL ES and WebGL
Expand Down Expand Up @@ -304,7 +305,7 @@ impl std::fmt::Debug for Context {
}

impl std::ops::Deref for Context {
type Target = Arc<crate::context::Context>;
type Target = Rc<crate::context::Context>;
fn deref(&self) -> &Self::Target {
&self.context
}
Expand Down
11 changes: 6 additions & 5 deletions src/gui/egui_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl GUI {
///
/// Creates a new GUI from a low-level graphics [Context](crate::context::Context).
///
pub fn from_gl_context(context: std::sync::Arc<crate::context::Context>) -> Self {
pub fn from_gl_context(context: std::rc::Rc<crate::context::Context>) -> Self {
GUI {
egui_context: egui::Context::default(),
painter: RefCell::new(Painter::new(context, "", None).unwrap()),
Expand Down Expand Up @@ -66,7 +66,6 @@ impl GUI {
+ viewport.height as f32 / device_pixel_ratio as f32,
},
}),
pixels_per_point: Some(device_pixel_ratio as f32),
time: Some(accumulated_time_in_ms * 0.001),
modifiers: (&self.modifiers).into(),
events: events
Expand Down Expand Up @@ -245,11 +244,13 @@ impl GUI {
.borrow_mut()
.take()
.expect("need to call GUI::update before GUI::render");
let clipped_meshes = self.egui_context.tessellate(output.shapes);
let scale = self.egui_context.pixels_per_point();
let pixels_per_point = self.egui_context.pixels_per_point();
let clipped_meshes = self
.egui_context
.tessellate(output.shapes, pixels_per_point);
self.painter.borrow_mut().paint_and_update_textures(
[self.viewport.width, self.viewport.height],
scale,
pixels_per_point,
&clipped_meshes,
&output.textures_delta,
);
Expand Down
4 changes: 2 additions & 2 deletions src/window/winit_window/windowed_context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::Context;
use crate::SurfaceSettings;
use crate::WindowError;
use std::sync::Arc;
use std::rc::Rc;
use winit::window::Window;

#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -193,7 +193,7 @@ mod inner {
gl_surface.set_swap_interval(&gl_context, swap_interval)?;

Ok(Self {
context: Context::from_gl_context(Arc::new(unsafe {
context: Context::from_gl_context(Rc::new(unsafe {
crate::context::Context::from_loader_function(|s| {
let s = std::ffi::CString::new(s)
.expect("failed to construct C string from string for gl proc address");
Expand Down