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

Implementation of UI wrapper #7

Merged
merged 15 commits into from
Aug 21, 2019
Merged

Implementation of UI wrapper #7

merged 15 commits into from
Aug 21, 2019

Conversation

ondrowan
Copy link
Collaborator

This is a convenience wrapper around imgui and all of its orchestration. Its practicality can be questioned, but it's the first iteration and I find it to be friendlier than the barebones alternative. All options are also hardcoded, which I (partly) don't expect to stay that way in the future.

@ondrowan ondrowan requested a review from yanchith August 19, 2019 11:32
Copy link
Member

@yanchith yanchith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

Except for ui_capture_{keyboard,mouse} and the vulkan validation layer errors, all my comments are minor and easily fixable.

Note: either the FPS computation is broken, or vsync doesn't work, got 2000fps on debug builds and over 9000 on release builds 😄
Would explain the GPU usage.

src/main.rs Outdated Show resolved Hide resolved
src/ui.rs Outdated Show resolved Hide resolved
src/shaders/imgui.vert Outdated Show resolved Hide resolved
src/shaders/imgui.frag Outdated Show resolved Hide resolved
src/shaders/imgui.frag Outdated Show resolved Hide resolved
src/ui.rs Outdated Show resolved Hide resolved
src/ui.rs Outdated Show resolved Hide resolved
src/imgui_renderer.rs Outdated Show resolved Hide resolved
src/imgui_renderer.rs Outdated Show resolved Hide resolved
src/imgui_renderer.rs Show resolved Hide resolved
Values in IO structure are updated after the current imgui's frame starts.
Therefore our calls to `want_capture_mouse` and `want_capture_keyboard` had
outdated values. This also didn't work well with `UI::create` and its
callback. So I removed the whole UI wrapper and work directly with
barebones calls to all involved libraries. All of this orchestration is
present only in `main` and doesn't leak to other modules, so it's a good
compromise.
@ondrowan ondrowan requested a review from yanchith August 21, 2019 15:27
@@ -129,7 +130,8 @@ impl ImguiRenderer {
depth_stencil_state: None,
index_format: wgpu::IndexFormat::Uint16, // FIXME(yanchith): may need 32bit indices!
vertex_buffers: &[wgpu::VertexBufferDescriptor {
stride: u64::try_from(Self::DRAW_VERT_SIZE).unwrap(),
stride: u64::try_from(wgpu_size_of::<imgui::DrawVert>())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant try_from, wgpu_size_of already returns u64 (type aliased as wgpu::BufferAddress)

@@ -105,14 +105,41 @@ fn main() {
let duration_running = now.duration_since(time_start);
time = now;

let duration_last_frame_s = duration_last_frame.as_secs() as f32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can leave a FIXME here to change to https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f32 when it stabilizes in 1.38.0

Copy link
Member

@yanchith yanchith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful 👍

@ondrowan ondrowan merged commit 6fb0feb into master Aug 21, 2019
@ondrowan ondrowan deleted the imgui branch August 21, 2019 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants