Don't show window if not ready to render

This commit is contained in:
Thomas Forgione 2018-04-11 17:11:55 +02:00
parent 211f7fc5c5
commit 53137b9d89
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
2 changed files with 17 additions and 3 deletions

View File

@ -58,13 +58,13 @@ fn main() {
}
let mut events_loop = EventsLoop::new();
let window = WindowBuilder::new();
let window = WindowBuilder::new().with_visibility(false);
let context = glutin::ContextBuilder::new().with_depth_buffer(24);
let display = Display::new(window, context, &events_loop).unwrap();
let mut renderer = Renderer::new(display);
let mut closed = false;
let mut renderer = Renderer::new(display);
renderer.add_model(&model);
let mut camera = Camera::new(
@ -75,6 +75,8 @@ fn main() {
let mut controls = OrbitControls::around(&model, &mut camera);
renderer.show();
while !closed {
events_loop.poll_events(|ev| {

View File

@ -113,7 +113,6 @@ impl<'a, D: Drawer + Facade + Sized> Renderer<'a, D> {
panic!()
}
}
/// Adds a model to the renderer, and compute the corresponding buffers for rendering.
@ -203,3 +202,16 @@ impl<'a, D: Drawer + Facade + Sized> Renderer<'a, D> {
}
}
impl<'a> Renderer<'a, Display> {
/// Shows the window if it was hidden.
pub fn show(&mut self) {
self.drawer.gl_window().show();
}
/// Hides the window if it was visible.
pub fn hide(&mut self) {
self.drawer.gl_window().hide();
}
}