michaelfairley / rust-imgui-opengl-renderer

OpenGL (3+) rendering for imgui-rs
37 stars 32 forks source link

Do not work anymore after upgrade to 0.2.3 #2

Closed ArnaudValensi closed 6 years ago

ArnaudValensi commented 6 years ago

Hi, I've upgraded from the commit Work with high DPI to 0.2.3, but imgui is not displaying anymore. Have you experienced the same thing? Do you have an idea how I can fix this?

Here my diff for the update:

index 78941e5..db5ba67 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,8 +12,8 @@ floating-duration = "0.1.2"
 dot_vox = "1.0.0"
 error-chain = "0.12.0"
 specs = "0.11"
-imgui-opengl-renderer = { path = "../rust-imgui-opengl-renderer" }
-imgui = "0.0.19-pre"
+imgui-opengl-renderer = "0.2.3"
+imgui = "0.0.20"

 [patch.crates-io]
-imgui = { git = "https://github.com/Gekkio/imgui-rs.git" }
+imgui = { git = "https://github.com/Gekkio/imgui-rs.git" }
diff --git a/src/systems/gui_rendering.rs b/src/systems/gui_rendering.rs
index 648e123..8117918 100644
--- a/src/systems/gui_rendering.rs
+++ b/src/systems/gui_rendering.rs
@@ -54,18 +54,18 @@ impl<'a> System<'a> for GuiRendering {
         let delta_time_in_seconds = time.get_delta_time_in_seconds();
         let gl_window = &self.window.borrow().gl_window;

-        let size_pixels = gl_window.get_inner_size().unwrap();
-        let hdipi = gl_window.hidpi_factor();
-        let size_points = (
-            (size_pixels.0 as f32 / hdipi) as u32,
-            (size_pixels.1 as f32 / hdipi) as u32,
-        );
+        let logical_size = gl_window.get_inner_size().unwrap();
+        let hidpi_factor = gl_window.hidpi_factor() as f64;
+        let frame_size = FrameSize {
+            logical_size: (logical_size.0 as f64, logical_size.1 as f64),
+            hidpi_factor,
+        };

         update_mouse(&mut self.imgui, &input);

         let ui = self
             .imgui
-            .frame(size_points, size_pixels, delta_time_in_seconds);
+            .frame(frame_size, delta_time_in_seconds);

         // let mut open = true;
         // ui.show_demo_window(&mut open);
@@ -140,7 +140,7 @@ fn update_mouse(imgui: &mut ImGui, input: &Input) {
         mouse_position.1 as f32 / scale.1,
     );

-    imgui.set_mouse_down(&[
+    imgui.set_mouse_down([
         input.get_mouse_left(),
         input.get_mouse_right(),
         input.get_mouse_middle(),
michaelfairley commented 6 years ago

Hi!

Things seem to be working fine with 0.2.3 in my projects.

I'd recommend deleting

[patch.crates-io]
imgui = { git = "https://github.com/Gekkio/imgui-rs.git" }

as it's not needed anymore now that all of the features from imgui-rs that this project needs are in released versions.

ArnaudValensi commented 6 years ago

Ok, thanks. My game compiles and runs but I don't see imgui windows anymore. Maybe something changed in imgui or I'm not using it correctly. I'm closing since it seems to be more an imgui issue.