-
-fn main() {
- let display = glium::glutin::WindowBuilder::new()
- .with_dimensions(1024, 768)
- .with_depth_buffer(24)
- .with_title(format!("MandelWow"))
- .build_glium()
- .unwrap();
-
- let mut camera = support::camera::CameraState::new();
- let mut t: f32 = 0.0;
- let mut z = [ 0.0, 0.0f32 ];
- let mut pause = false;
-
- support::start_loop(|| {
- camera.update();
-
- if !pause {
- // Increment time
- t += 0.01;
- }
-
- // Compute a sine wave slicing the Mandelwow along its 4th dimension.
- let wmin = -0.8;
- let wmax = 0.8;
- let wsize = wmax - wmin;
- let mandel_w = ((t.sin() + 1.0) / 2.0) * wsize + wmin;
-
- //println!("t={} z={:?} camera={:?}", t, z, camera.get_pos());
-
- let mut frame = display.draw();
- frame.clear_color_and_depth((0.0, 0.0, 0.0, 1.0), 1.0);
-
- let z_trans = -2.0; // How far back to move the model
- let model = [
- [ t.cos(), t.sin(), 0.0, 0.0],
- [-t.sin(), t.cos(), 0.0, 0.0],
- [ 0.0, 0.0, 1.0, 0.0],
- [ 0.0, 0.0, z_trans, 1.0f32]
- ];
-
- let program = mandelwow_program(&display);
- let bounding_box_program = solid_fill_program(&display);
-
- let bounds = Cube {
- xmin: -2.0,
- xmax: 0.7,
- ymin: -1.0,
- ymax: 1.0,
- zmin: -1.2,
- zmax: 1.2,
- };
-
- mandelwow(&display, &mut frame, &program, model, &camera, &bounds, mandel_w);
-
- let uniforms = uniform! {
- model: model,
- view: camera.get_view(),
- perspective: camera.get_perspective(),
- };
- bounding_box(&display, &mut frame, &bounding_box_program, &uniforms, &bounds);
-
- for ev in display.poll_events() {
- match ev {
- glium::glutin::Event::Closed => {
- frame.finish().unwrap();
- return support::Action::Stop
- },
- glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::VirtualKeyCode::PageUp)) => {
- t += 0.01;
- },
- glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::VirtualKeyCode::PageDown)) => {
- t -= 0.01;
- },
- glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::VirtualKeyCode::P)) => {
- pause ^= true;
- },
- ev => camera.process_input(&ev),
- }
- }
-
- frame.finish().unwrap();
- support::Action::Continue
- });
-}