mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-12 05:58:35 +00:00
Update gfx_window_glutin to 0.25, glium to 0.22 and glutin to 0.17 in imgui-examples and fix errors
This commit is contained in:
parent
ebc81d2767
commit
b1ebd720e7
@ -10,9 +10,9 @@ publish = false
|
||||
|
||||
[dev-dependencies]
|
||||
gfx = "0.17"
|
||||
gfx_window_glutin = "0.22"
|
||||
glium = { version = "0.21", default-features = true }
|
||||
glutin = "0.14"
|
||||
gfx_window_glutin = "0.25"
|
||||
glium = { version = "0.22", default-features = true }
|
||||
glutin = "0.17"
|
||||
imgui = { version = "0.0.19-pre", path = "../" }
|
||||
imgui-gfx-renderer = { version = "0.0.19-pre", path = "../imgui-gfx-renderer" }
|
||||
imgui-glium-renderer = { version = "0.0.19-pre", path = "../imgui-glium-renderer" }
|
||||
|
||||
@ -17,7 +17,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let context = glutin::ContextBuilder::new().with_vsync(true);
|
||||
let window = glutin::WindowBuilder::new()
|
||||
.with_title(title)
|
||||
.with_dimensions(1024, 768);
|
||||
.with_dimensions(glutin::dpi::LogicalSize::new(1024f64, 768f64));
|
||||
let display = Display::new(window, context, &events_loop).unwrap();
|
||||
|
||||
let mut imgui = ImGui::init();
|
||||
@ -42,7 +42,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
|
||||
if let Event::WindowEvent { event, .. } = event {
|
||||
match event {
|
||||
Closed => quit = true,
|
||||
CloseRequested => quit = true,
|
||||
KeyboardInput { input, .. } => {
|
||||
use glium::glutin::VirtualKeyCode as Key;
|
||||
|
||||
@ -76,7 +76,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
CursorMoved { position: (x, y), .. } => mouse_state.pos = (x as i32, y as i32),
|
||||
CursorMoved { position: pos, .. } => mouse_state.pos = pos.into(),
|
||||
MouseInput { state, button, .. } => {
|
||||
match button {
|
||||
MouseButton::Left => mouse_state.pressed.0 = state == Pressed,
|
||||
@ -89,12 +89,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
delta: MouseScrollDelta::LineDelta(_, y),
|
||||
phase: TouchPhase::Moved,
|
||||
..
|
||||
} |
|
||||
} => mouse_state.wheel = y,
|
||||
MouseWheel {
|
||||
delta: MouseScrollDelta::PixelDelta(_, y),
|
||||
delta: MouseScrollDelta::PixelDelta(pos),
|
||||
phase: TouchPhase::Moved,
|
||||
..
|
||||
} => mouse_state.wheel = y,
|
||||
} => mouse_state.wheel = pos.y as f32,
|
||||
ReceivedCharacter(c) => imgui.add_input_character(c),
|
||||
_ => (),
|
||||
}
|
||||
@ -113,10 +113,10 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let mouse_cursor = imgui.mouse_cursor();
|
||||
if imgui.mouse_draw_cursor() || mouse_cursor == ImGuiMouseCursor::None {
|
||||
// Hide OS cursor
|
||||
gl_window.set_cursor_state(glutin::CursorState::Hide).unwrap();
|
||||
gl_window.hide_cursor(true);
|
||||
} else {
|
||||
// Set OS cursor
|
||||
gl_window.set_cursor_state(glutin::CursorState::Normal).unwrap();
|
||||
gl_window.hide_cursor(false);
|
||||
gl_window.set_cursor(match mouse_cursor {
|
||||
ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"),
|
||||
ImGuiMouseCursor::Arrow => glutin::MouseCursor::Arrow,
|
||||
@ -130,13 +130,13 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
}
|
||||
|
||||
let size_pixels = gl_window.get_inner_size().unwrap();
|
||||
let hdipi = gl_window.hidpi_factor();
|
||||
let hdipi = gl_window.get_hidpi_factor();
|
||||
let size_points = (
|
||||
(size_pixels.0 as f32 / hdipi) as u32,
|
||||
(size_pixels.1 as f32 / hdipi) as u32,
|
||||
(size_pixels.width as f64 / hdipi) as u32,
|
||||
(size_pixels.height as f64 / hdipi) as u32,
|
||||
);
|
||||
|
||||
let ui = imgui.frame(size_points, size_pixels, delta_s);
|
||||
let ui = imgui.frame(size_points, size_pixels.into(), delta_s);
|
||||
if !run_ui(&ui) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let context = glutin::ContextBuilder::new().with_vsync(true);
|
||||
let window = glutin::WindowBuilder::new()
|
||||
.with_title(title)
|
||||
.with_dimensions(1024, 768);
|
||||
.with_dimensions(glutin::dpi::LogicalSize::new(1024f64, 768f64));
|
||||
let (window, mut device, mut factory, mut main_color, mut main_depth) =
|
||||
gfx_window_glutin::init::<ColorFormat, DepthFormat>(window, context, &events_loop);
|
||||
let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into();
|
||||
@ -82,11 +82,11 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
|
||||
if let Event::WindowEvent { event, .. } = event {
|
||||
match event {
|
||||
Resized(_, _) => {
|
||||
Resized(_) => {
|
||||
gfx_window_glutin::update_views(&window, &mut main_color, &mut main_depth);
|
||||
renderer.update_render_target(main_color.clone());
|
||||
}
|
||||
Closed => quit = true,
|
||||
CloseRequested => quit = true,
|
||||
KeyboardInput { input, .. } => {
|
||||
use glutin::VirtualKeyCode as Key;
|
||||
|
||||
@ -120,7 +120,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
CursorMoved { position: (x, y), .. } => mouse_state.pos = (x as i32, y as i32),
|
||||
CursorMoved { position: pos, .. } => mouse_state.pos = pos.into(),
|
||||
MouseInput { state, button, .. } => {
|
||||
match button {
|
||||
MouseButton::Left => mouse_state.pressed.0 = state == Pressed,
|
||||
@ -133,12 +133,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
delta: MouseScrollDelta::LineDelta(_, y),
|
||||
phase: TouchPhase::Moved,
|
||||
..
|
||||
} |
|
||||
} => mouse_state.wheel = y,
|
||||
MouseWheel {
|
||||
delta: MouseScrollDelta::PixelDelta(_, y),
|
||||
delta: MouseScrollDelta::PixelDelta(pos),
|
||||
phase: TouchPhase::Moved,
|
||||
..
|
||||
} => mouse_state.wheel = y,
|
||||
} => mouse_state.wheel = pos.y as f32,
|
||||
ReceivedCharacter(c) => imgui.add_input_character(c),
|
||||
_ => (),
|
||||
}
|
||||
@ -158,10 +158,10 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let mouse_cursor = imgui.mouse_cursor();
|
||||
if imgui.mouse_draw_cursor() || mouse_cursor == ImGuiMouseCursor::None {
|
||||
// Hide OS cursor
|
||||
window.set_cursor_state(glutin::CursorState::Hide).unwrap();
|
||||
window.hide_cursor(true);
|
||||
} else {
|
||||
// Set OS cursor
|
||||
window.set_cursor_state(glutin::CursorState::Normal).unwrap();
|
||||
window.hide_cursor(false);
|
||||
window.set_cursor(match mouse_cursor {
|
||||
ImGuiMouseCursor::None => unreachable!("mouse_cursor was None!"),
|
||||
ImGuiMouseCursor::Arrow => glutin::MouseCursor::Arrow,
|
||||
@ -175,13 +175,13 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
}
|
||||
|
||||
let size_pixels = window.get_inner_size().unwrap();
|
||||
let hdipi = window.hidpi_factor();
|
||||
let hdipi = window.get_hidpi_factor();
|
||||
let size_points = (
|
||||
(size_pixels.0 as f32 / hdipi) as u32,
|
||||
(size_pixels.1 as f32 / hdipi) as u32,
|
||||
(size_pixels.width as f64 / hdipi) as u32,
|
||||
(size_pixels.height as f64 / hdipi) as u32,
|
||||
);
|
||||
|
||||
let ui = imgui.frame(size_points, size_pixels, delta_s);
|
||||
let ui = imgui.frame(size_points, size_pixels.into(), delta_s);
|
||||
if !run_ui(&ui) {
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user