mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-14 06:58:35 +00:00
Make winit 0.20+ the default
This commit is contained in:
parent
2d2f4fe4ef
commit
1e1b17b874
@ -22,7 +22,7 @@ glutin = "0.21"
|
||||
image = "0.22"
|
||||
imgui = { version = "0.3.0-pre", path = "../" }
|
||||
imgui-gfx-renderer = { version = "0.3.0-pre", path = "../imgui-gfx-renderer" }
|
||||
imgui-winit-support = { version = "0.3.0-pre", path = "../imgui-winit-support" }
|
||||
imgui-winit-support = { version = "0.3.0-pre", path = "../imgui-winit-support", default-features = false, features = ["winit-19"] }
|
||||
|
||||
[target.'cfg(windows)'.dev-dependencies]
|
||||
gfx_device_dx11 = "0.8"
|
||||
|
||||
@ -15,4 +15,4 @@ winit-19 = { version = ">= 0.16, <= 0.19", package = "winit", optional = true }
|
||||
winit-20 = { version = ">= 0.20", package = "winit", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["winit-19"]
|
||||
default = ["winit-20"]
|
||||
|
||||
@ -12,18 +12,20 @@
|
||||
//! 4. Call frame preparation callback (every frame)
|
||||
//! 5. Call render preparation callback (every frame)
|
||||
//!
|
||||
//! ## Complete example (without a renderer)
|
||||
//! ## Complete example for winit 0.20+ (without a renderer)
|
||||
//!
|
||||
//! ```rust,no_run,ignore
|
||||
//! # // TODO: Remove ignore when updated to winit 0.20
|
||||
//! # // TODO: Remove ignore when only one winit version is used
|
||||
//! use imgui::Context;
|
||||
//! use imgui_winit_support::{HiDpiMode, WinitPlatform};
|
||||
//! use std::time::Instant;
|
||||
//! use winit::{Event, EventsLoop, Window, WindowEvent};
|
||||
//! use winit::event::{Event, WindowEvent};
|
||||
//! use winit::event_loop::{ControlFlow, EventLoop};
|
||||
//! use winit::window::{Window};
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let mut events_loop = EventsLoop::new();
|
||||
//! let mut window = Window::new(&events_loop).unwrap();
|
||||
//! let mut event_loop = EventLoop::new();
|
||||
//! let mut window = Window::new(&event_loop).unwrap();
|
||||
//!
|
||||
//! let mut imgui = Context::create();
|
||||
//! // configure imgui-rs Context if necessary
|
||||
@ -33,36 +35,41 @@
|
||||
//!
|
||||
//! let mut last_frame = Instant::now();
|
||||
//! let mut run = true;
|
||||
//! while run {
|
||||
//! events_loop.poll_events(|event| {
|
||||
//! platform.handle_event(imgui.io_mut(), &window, &event); // step 3
|
||||
//!
|
||||
//! // application-specific event handling
|
||||
//! // for example:
|
||||
//! if let Event::WindowEvent { event, .. } = event {
|
||||
//! match event {
|
||||
//! WindowEvent::CloseRequested => run = false,
|
||||
//! _ => (),
|
||||
//! }
|
||||
//! event_loop.run(move |event, _, control_flow| {
|
||||
//! match event {
|
||||
//! Event::NewEvents(_) => {
|
||||
//! // other application-specific logic
|
||||
//! last_frame = imgui.io_mut().update_delta_time(last_frame);
|
||||
//! },
|
||||
//! Event::MainEventsCleared => {
|
||||
//! // other application-specific logic
|
||||
//! platform.prepare_frame(imgui.io_mut(), &window) // step 4
|
||||
//! .expect("Failed to prepare frame");
|
||||
//! window.request_redraw();
|
||||
//! }
|
||||
//! });
|
||||
//! Event::RedrawRequested(_) => {
|
||||
//! let ui = imgui.frame();
|
||||
//! // application-specific rendering *under the UI*
|
||||
//!
|
||||
//! platform.prepare_frame(imgui.io_mut(), &window) // step 4
|
||||
//! .expect("Failed to prepare frame");
|
||||
//! last_frame = imgui.io_mut().update_delta_time(last_frame);
|
||||
//! let ui = imgui.frame();
|
||||
//! // construct the UI
|
||||
//!
|
||||
//! // application-specific rendering *under the UI*
|
||||
//! platform.prepare_render(&ui, &window); // step 5
|
||||
//! // render the UI with a renderer
|
||||
//! let draw_data = ui.render();
|
||||
//! // renderer.render(..., draw_data).expect("UI rendering failed");
|
||||
//!
|
||||
//! // construct the UI
|
||||
//!
|
||||
//! platform.prepare_render(&ui, &window); // step 5
|
||||
//! // render the UI with a renderer
|
||||
//! let draw_data = ui.render();
|
||||
//! // renderer.render(..., draw_data).expect("UI rendering failed");
|
||||
//!
|
||||
//! // application-specific rendering *over the UI*
|
||||
//! }
|
||||
//! // application-specific rendering *over the UI*
|
||||
//! },
|
||||
//! Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
||||
//! *control_flow = ControlFlow::Exit;
|
||||
//! }
|
||||
//! // other application-specific event handling
|
||||
//! event => {
|
||||
//! platform.handle_event(imgui.io_mut(), &window, &event); // step 3
|
||||
//! // other application-specific event handling
|
||||
//! }
|
||||
//! }
|
||||
//! })
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user