X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=main.rs;h=d00c783ebdaa3c4e6056c1d5f221249a5e0464b7;hb=fb92205ecfb5397f4cb3d47baee5da1f063ec892;hp=86421b4941a7c1c68b1462ef3e26d13e6168df9b;hpb=9ae471dda58c74e83c7080f7ea527105e063aef3;p=mandelwow.git diff --git a/main.rs b/main.rs index 86421b4..d00c783 100644 --- a/main.rs +++ b/main.rs @@ -1,12 +1,12 @@ use cgmath::conv::array4x4; use cgmath::{Euler, Matrix4, Rad, SquareMatrix, Vector3, Vector4, Zero}; use glium::glutin::event::{ self, Event, VirtualKeyCode, WindowEvent }; -use glium::glutin::event_loop::{ ControlFlow }; +use glium::glutin::event_loop::ControlFlow; use glium::{Display, Program, Surface, uniform}; +use instant::Duration; use mandelwow_lib::*; use std::f32::consts::PI; use std::rc::Rc; -use std::time::{Duration, Instant}; #[cfg(target_os = "emscripten")] use std::os::raw::{c_int, c_void}; @@ -249,7 +249,7 @@ fn main() { emscripten_GetProcAddress(addr.into_raw() as *const _) as *const _ }); gl.glGetInternalformativ(0, 0, 0, 0, 0); -*/ + */ let mut soundplayer = sound::start(); @@ -274,9 +274,10 @@ fn main() { let mut timer = Timer::new(); let mut camera = support::camera::CameraState::new(); - let mut fullscreen = true; + let mut fullscreen = false; event_loop.run(move |event, _, control_flow| { + timer.update(); let t = timer.t; let new_hit = sound::hit_event(&mut soundplayer); if new_hit > world.last_hit { @@ -286,12 +287,15 @@ fn main() { camera.update(); - *control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::from_nanos(16_666_667)); + *control_flow = ControlFlow::WaitUntil(timer.now + Duration::from_nanos(16_666_667)); match event { + Event::MainEventsCleared => { + world.draw_frame(&display, &camera, t); + } Event::NewEvents(cause) => { match cause { event::StartCause::ResumeTimeReached { .. } | event::StartCause::Init => { - world.draw_frame(&display, &camera, t); + // FIXME }, _ => {} } @@ -312,12 +316,12 @@ fn main() { VirtualKeyCode::PageUp => timer.t += 0.1, VirtualKeyCode::PageDown => timer.t -= 0.2, VirtualKeyCode::F10 => screenshot::take_screenshot(&display), - VirtualKeyCode::F11 | VirtualKeyCode::Return => { + VirtualKeyCode::F | VirtualKeyCode::F11 | VirtualKeyCode::Return => { fullscreen ^= true; let fs = if fullscreen { - let monitor_handle = display.gl_window().window() - .available_monitors().next().unwrap(); - Some(glium::glutin::window::Fullscreen::Borderless(monitor_handle)) + // let monitor_handle = display.gl_window().window() + // .available_monitors().next().unwrap(); + Some(glium::glutin::window::Fullscreen::Borderless(None)) } else { None }; @@ -333,7 +337,5 @@ fn main() { }, _ => (), } - - timer.update(); }); }