Update examples, glium is the leading renderer again

This commit is contained in:
Joonas Javanainen 2019-06-27 22:12:07 +03:00
parent 42d3c0f6d7
commit d9e5ea37e7
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179
18 changed files with 655 additions and 659 deletions

View File

@ -30,5 +30,5 @@ script:
- cargo test --all --verbose - cargo test --all --verbose
- cargo build --all --verbose --manifest-path imgui-examples/Cargo.toml - cargo build --all --verbose --manifest-path imgui-examples/Cargo.toml
- cargo test --all --verbose --manifest-path imgui-examples/Cargo.toml - cargo test --all --verbose --manifest-path imgui-examples/Cargo.toml
- cargo build --all --verbose --manifest-path imgui-glium-examples/Cargo.toml - cargo build --all --verbose --manifest-path imgui-gfx-examples/Cargo.toml
- cargo test --all --verbose --manifest-path imgui-glium-examples/Cargo.toml - cargo test --all --verbose --manifest-path imgui-gfx-examples/Cargo.toml

View File

@ -33,6 +33,6 @@ members = [
] ]
exclude = [ exclude = [
"imgui-examples", "imgui-examples",
"imgui-glium-examples", "imgui-gfx-examples",
"imgui-sys-bindgen" "imgui-sys-bindgen"
] ]

View File

@ -33,7 +33,7 @@ ui.window(im_str!("Hello world"))
* Not horrible way of defining and passing null-terminated UTF-8 to ImGui. * Not horrible way of defining and passing null-terminated UTF-8 to ImGui.
The macro `im_str!` needs to be used most of the time. For more The macro `im_str!` needs to be used most of the time. For more
information and justification for this design, please see [issue #7](https://github.com/Gekkio/imgui-rs/issues/7) information and justification for this design, please see [issue #7](https://github.com/Gekkio/imgui-rs/issues/7)
* Parts of imgui\_demo.cpp reimplemented in Rust as an API usage example (examples/test\_window\_impl.rs) * Parts of imgui\_demo.cpp reimplemented in Rust as an API usage example (imgui-examples/examples/test\_window\_impl.rs)
## Important but unimplemented things ## Important but unimplemented things
@ -56,23 +56,23 @@ ui.window(im_str!("Hello world"))
cd imgui-rs cd imgui-rs
git submodule update --init --recursive git submodule update --init --recursive
Examples for gfx backend are under the imgui-examples directory. Main examples are located in the imgui-examples directory.
cd imgui-examples
cargo test
cargo run --example hello_gfx
Examples for glium backend are located into the imgui-glium-examples directory.
# At the reposity root # At the reposity root
cd imgui-glium-examples cd imgui-examples
cargo test cargo test
cargo run --example hello_world cargo run --example hello_world
cargo run --example test_window cargo run --example test_window
cargo run --example test_window_impl cargo run --example test_window_impl
Examples for the gfx backend are under the imgui-gfx-examples directory.
cd imgui-gfx-examples
cargo test
cargo run --example hello_gfx
Note to Windows users: You will need to use the *MSVC ABI* version of the Rust compiler along Note to Windows users: You will need to use the *MSVC ABI* version of the Rust compiler along
with its associated [dependencies](https://www.rust-lang.org/en-US/downloads.html#win-foot) to with its associated [dependencies](https://www.rust-lang.org/en-US/downloads.html#win-foot) to
build this libary and run the examples. build this libary and run the examples.

File diff suppressed because it is too large Load Diff

View File

@ -3,24 +3,15 @@ name = "imgui-examples"
version = "0.0.24-pre" version = "0.0.24-pre"
edition = "2018" edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"] authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "imgui crate examples" description = "imgui crate examples using Glium backend"
homepage = "https://github.com/Gekkio/imgui-rs" homepage = "https://github.com/Gekkio/imgui-rs"
repository = "https://github.com/Gekkio/imgui-rs" repository = "https://github.com/Gekkio/imgui-rs"
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
publish = false publish = false
[features]
opengl = ["imgui-gfx-renderer/opengl"]
directx = ["imgui-gfx-renderer/directx"]
default = ["opengl"]
[dev-dependencies] [dev-dependencies]
gfx = "0.18" glium = { version = "0.25", default-features = true }
gfx_window_glutin = "0.30"
glutin = "0.20"
imgui = { version = "0.0.24-pre", path = "../" } imgui = { version = "0.0.24-pre", path = "../" }
imgui-gfx-renderer = { version = "0.0.24-pre", path = "../imgui-gfx-renderer" } imgui-glium-renderer = { version = "0.0.24-pre", path = "../imgui-glium-renderer" }
imgui-winit-support = { version = "0.0.24-pre", path = "../imgui-winit-support" } imgui-winit-support = { version = "0.0.24-pre", path = "../imgui-winit-support" }
image = "0.21"
[target.'cfg(windows)'.dev-dependencies]
gfx_window_dxgi = "0.19"

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,26 @@
[package] [package]
name = "imgui-glium-examples" name = "imgui-gfx-examples"
version = "0.0.24-pre" version = "0.0.24-pre"
edition = "2018" edition = "2018"
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"] authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
description = "imgui crate examples using Glium backend" description = "imgui crate examples"
homepage = "https://github.com/Gekkio/imgui-rs" homepage = "https://github.com/Gekkio/imgui-rs"
repository = "https://github.com/Gekkio/imgui-rs" repository = "https://github.com/Gekkio/imgui-rs"
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
publish = false publish = false
[features]
opengl = ["imgui-gfx-renderer/opengl"]
directx = ["imgui-gfx-renderer/directx"]
default = ["opengl"]
[dev-dependencies] [dev-dependencies]
glium = { version = "0.25", default-features = true } gfx = "0.18"
gfx_window_glutin = "0.31"
glutin = "0.21"
imgui = { version = "0.0.24-pre", path = "../" } imgui = { version = "0.0.24-pre", path = "../" }
imgui-glium-renderer = { version = "0.0.24-pre", path = "../imgui-glium-renderer" } imgui-gfx-renderer = { version = "0.0.24-pre", path = "../imgui-gfx-renderer" }
imgui-winit-support = { version = "0.0.24-pre", path = "../imgui-winit-support" } imgui-winit-support = { version = "0.0.24-pre", path = "../imgui-winit-support" }
image = "0.21"
[target.'cfg(windows)'.dev-dependencies]
gfx_window_dxgi = "0.19"

View File

@ -1,4 +1,4 @@
# `imgui-examples` # `imgui-gfx-examples`
- Run with OpenGL backend: `cargo run --example hello_gfx` - Run with OpenGL backend: `cargo run --example hello_gfx`
- Run with DirectX backend: `cargo run --example hello_gfx --features directx --no-default-features` - Run with DirectX backend: `cargo run --example hello_gfx --features directx --no-default-features`

View File

@ -15,7 +15,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
let builder = glutin::WindowBuilder::new() let builder = glutin::WindowBuilder::new()
.with_title(title.to_owned()) .with_title(title.to_owned())
.with_dimensions(glutin::dpi::LogicalSize::new(1024f64, 768f64)); .with_dimensions(glutin::dpi::LogicalSize::new(1024f64, 768f64));
let (window, mut device, mut factory, mut main_color, mut main_depth) = let (windowed_context, mut device, mut factory, mut main_color, mut main_depth) =
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder, context, &events_loop) gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder, context, &events_loop)
.expect("Failed to initalize graphics"); .expect("Failed to initalize graphics");
let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into(); let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into();
@ -60,7 +60,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
imgui.set_ini_filename(None); imgui.set_ini_filename(None);
let mut platform = WinitPlatform::init(&mut imgui); let mut platform = WinitPlatform::init(&mut imgui);
platform.attach_window(imgui.io_mut(), &window, HiDpiMode::Rounded); platform.attach_window(imgui.io_mut(), &windowed_context.window(), HiDpiMode::Rounded);
let hidpi_factor = platform.hidpi_factor(); let hidpi_factor = platform.hidpi_factor();
let font_size = (13.0 * hidpi_factor) as f32; let font_size = (13.0 * hidpi_factor) as f32;
@ -93,12 +93,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
loop { loop {
events_loop.poll_events(|event| { events_loop.poll_events(|event| {
platform.handle_event(imgui.io_mut(), &window, &event); platform.handle_event(imgui.io_mut(), &windowed_context.window(), &event);
if let Event::WindowEvent { event, .. } = event { if let Event::WindowEvent { event, .. } = event {
match event { match event {
WindowEvent::Resized(_) => { WindowEvent::Resized(_) => {
gfx_window_glutin::update_views(&window, &mut main_color, &mut main_depth) gfx_window_glutin::update_views(&windowed_context, &mut main_color, &mut main_depth)
}, },
WindowEvent::CloseRequested => quit = true, WindowEvent::CloseRequested => quit = true,
_ => (), _ => (),
@ -110,7 +110,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
} }
let io = imgui.io_mut(); let io = imgui.io_mut();
platform.prepare_frame(io, &window).expect("Failed to start frame"); platform.prepare_frame(io, &windowed_context.window()).expect("Failed to start frame");
last_frame = io.update_delta_time(last_frame); last_frame = io.update_delta_time(last_frame);
let ui = imgui.frame(); let ui = imgui.frame();
@ -123,7 +123,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
.render(&mut factory, &mut encoder, &mut main_color, ui) .render(&mut factory, &mut encoder, &mut main_color, ui)
.expect("Rendering failed"); .expect("Rendering failed");
encoder.flush(&mut device); encoder.flush(&mut device);
window.swap_buffers().unwrap(); windowed_context.swap_buffers().unwrap();
device.cleanup(); device.cleanup();
} }
} }