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

App shows a blank window on start #750

Open
ghostman2013 opened this issue Nov 4, 2023 · 1 comment
Open

App shows a blank window on start #750

ghostman2013 opened this issue Nov 4, 2023 · 1 comment

Comments

@ghostman2013
Copy link

Description
I copied a code from an example: Hello, World!.
It's a total duplicate, project dependencies below:

[dependencies]
copypasta = "0.10.0"
glium = { version = "0.32.1", default-features = true }
imgui = { version = "0.11.0", features = ["freetype"] }
imgui-glium-renderer = "0.11.0"
imgui-winit-support = "0.11.0"
# Pin indirect dependency scoped-tls to 1.0.0
# as 1.0.1 bumped MSRV to 1.59
# Used only in
# imgui-examples -> glium -> glutin -> wayland-client -> scoped-tls
# so not worth bumping MSRV for this basically to keep CI happy
# FIXME: Remove this for imgui-rs v0.10 and bump MSRV
scoped-tls = "=1.0.0"

However, when I launch app it shows a blank window. If I resize the window at least a bit GUI begins showing well.

I have also tried to move a mouse pointer over this blank window and... It works! I mean the mouse cursor is changed like there are GUI controls under it. Everything works just invisible until you won't resize the window.

To Reproduce

  1. Run app
  2. Watch a blank window =)

Expected behavior

  1. Run app
  2. Watch an awesome ImGUI

Screenshots
Before resizing
Screenshot 2023-11-05 at 02 03 36
After resizing
Screenshot 2023-11-05 at 02 03 47

Please describe your environment
I use macOS (M1 Pro, Sonoma 14.2), rustc 1.75.0-nightly (a2f5f9691 2023-11-02)

Other information
If it's required I will provide any additional details about this bug

@EinarsNG
Copy link

EinarsNG commented Nov 16, 2023

There is a workout i found. It involves tinkering with the support/mod.rs file. Not sure if it's the best solution but it seems to work for me.
At the start of this

Event::RedrawRequested(_) => {
let ui = imgui.frame();
let mut run = true;
run_ui(&mut run, ui);
if !run {
*control_flow = ControlFlow::Exit;
}
let gl_window = display.gl_window();
let mut target = display.draw();
target.clear_color_srgb(1.0, 1.0, 1.0, 1.0);
platform.prepare_render(ui, gl_window.window());
let draw_data = imgui.render();
renderer
.render(&mut target, draw_data)
.expect("Rendering failed");
target.finish().expect("Failed to swap buffers");
}
match statement you can insert something like:

if last_frame.duration_since(first_frame).as_millis() > 100 {
    once_flag.call_once(|| {
        let gl_window = display.gl_window();
        let resize_window_event: Event<WindowEvent> = Event::WindowEvent {
            event: WindowEvent::Resized(gl_window.window().inner_size()),
            window_id: gl_window.window().id(),
        };
        platform.handle_event(
            imgui.io_mut(),
            gl_window.window(),
            &resize_window_event
        );
    });
}

Which will trigger a Resized event down the rendering pipeline 100ms after the window has started rendering.
you assign first_frame and once_flag before the event_loop.run.

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

No branches or pull requests

2 participants