Port to glium 0.22 and clutin 0.18
authorBernie Innocenti <codewiz@google.com>
Sat, 29 Sep 2018 12:13:36 +0000 (21:13 +0900)
committerBernie Innocenti <codewiz@google.com>
Sat, 29 Sep 2018 12:13:36 +0000 (21:13 +0900)
Cargo.toml
main.rs
support/camera.rs
support/vec3.rs

index 5698fae39563348eea0f421f0a25d04aede45b4b..5d8d3852693bba09231081291ee0e8a1cebf2b94 100644 (file)
@@ -1,8 +1,11 @@
+#cargo-features = ["edition"]
+
 [package]
 name = "mandelwow"
 version = "0.7.0"
 authors = ["Bernie Innocenti <bernie@codewiz.org>"]
 license = "GPL-3.0+"
+#edition = '2018'
 
 [profile.release]
 lto = true
@@ -11,8 +14,8 @@ opt-level = 3
 
 [dependencies]
 cgmath = "*"
-glium = "0.21"
-glutin = "0.14"
+glium = "0.22"
+glutin = "0.18"
 image = { version = "0.18", features = ["png_codec"], optional = true }
 libxm = "1.0.0"
 rust-rocket = { path = "rust-rocket", optional = true }
diff --git a/main.rs b/main.rs
index 02bb86a0a08cc119d9ae584ba1b56c657bf3b769..175fb611954950f9b921645dbd884f210b4c7aea 100644 (file)
--- a/main.rs
+++ b/main.rs
@@ -8,9 +8,8 @@ extern crate glutin;
 use cgmath::{Euler, Matrix4, Rad, SquareMatrix, Vector3, Vector4, Zero};
 use cgmath::conv::array4x4;
 use glium::{Surface};
-use glutin::ElementState::Pressed;
-use glutin::WindowEvent::KeyboardInput;
-use glutin::VirtualKeyCode;
+use glium::glutin::WindowEvent::KeyboardInput;
+use glium::glutin::VirtualKeyCode;
 use mandelwow_lib::*;
 use std::f32::consts::PI;
 use timer::Timer;
@@ -65,19 +64,20 @@ pub fn set_main_loop_callback<F>(callback : F) where F : FnMut() -> support::Act
 fn main() {
     let mut soundplayer = sound::start();
 
-    let mut events_loop = glutin::EventsLoop::new();
-    let window = glutin::WindowBuilder::new()
-        .with_dimensions(1280, 720)
-        //.with_fullscreen(glutin::get_primary_monitor())
-        .with_title("MandelWow");
-    let context = glutin::ContextBuilder::new()
-        .with_gl_profile(glutin::GlProfile::Core)
-        .with_depth_buffer(24)
+    let mut events_loop = glium::glutin::EventsLoop::new();
+    let window = glium::glutin::WindowBuilder::new()
+        //.with_dimensions(1280, 720)
+        .with_fullscreen(Some(events_loop.get_primary_monitor()));
+        //.with_title("MandelWow");
+    let context = glium::glutin::ContextBuilder::new()
+        //.with_gl_profile(glutin::GlProfile::Core)
+        //.with_gl(glutin::GlRequest::Specific(glutin::Api::WebGl, (2, 0)))
+        //.with_depth_buffer(24)
         .with_vsync(true);
     let display = glium::Display::new(window, context, &events_loop).unwrap();
     gl_info(&display);
 
-    let mut text = text::Text::new(&display, 'A');
+//    let mut text = text::Text::new(&display, 'A');
     let mandelwow_program = mandelwow::program(&display);
     let bounding_box_program = bounding_box::solid_fill_program(&display);
     let shaded_program = shaded_cube::shaded_program(&display);
@@ -181,10 +181,10 @@ fn main() {
                     col: [0., (1. - wave).abs() * 0.5,  wave.abs()],
                 };
                 shaded_cube.draw(&mut frame, &uniforms);
-                text.model = model * text_pos;
+/*                text.model = model * text_pos;
                 text.character = (x + z * SEA_XSIZE) as u8 as char;
                 text.draw(&mut frame, &perspview);
-            }
+*/            }
         }
 
         mandelwow::draw(&display, &mut frame, &mandelwow_program, model, &camera, &bounds, wow);
@@ -193,14 +193,14 @@ fn main() {
 
         let mut action = support::Action::Continue;
         events_loop.poll_events(|event| {
-            if let glutin::Event::WindowEvent { event, .. } = event {
+            if let glium::glutin::Event::WindowEvent { event, .. } = event {
                 camera.process_input(&event);
                 match event {
-                    glutin::WindowEvent::Closed => {
+                    glium::glutin::WindowEvent::CloseRequested => {
                         action = support::Action::Stop
                     },
                     KeyboardInput { input, .. } => {
-                        if input.state == glutin::ElementState::Pressed {
+                        if input.state == glium::glutin::ElementState::Pressed {
                             if let Some(key) = input.virtual_keycode {
                                 match key {
                                     VirtualKeyCode::Escape | VirtualKeyCode::Q => {
index b31b9e33c47d79e382e180f9feb5e0f3d8147fd3..8460197f5558dac493376e11d5c4e855faa55665 100644 (file)
@@ -1,9 +1,7 @@
-extern crate glutin;
-
 use cgmath::{Matrix4, Vector4};
 use cgmath::conv::array4x4;
-use glutin::WindowEvent::{KeyboardInput, CursorMoved};
-use glutin::VirtualKeyCode;
+use glium;
+use glium::glutin::VirtualKeyCode;
 use std::f32;
 use std::f32::consts::PI;
 use support::vec3::Vec3;
@@ -165,10 +163,10 @@ impl CameraState {
         //println!("camera_dir = {:?}", self.dir);
     }
 
-    pub fn process_input(&mut self, event: &glutin::WindowEvent) {
+    pub fn process_input(&mut self, event: &glium::glutin::WindowEvent) {
         match event {
-            &CursorMoved { position: (x, y), .. }  => {
-                let (x, y) = (x as i32, y as i32);
+            &glium::glutin::WindowEvent::CursorMoved { position, .. }  => {
+                let (x, y) = (position.x as i32, position.y as i32);
                 if self.mouse_x == -1 {
                     // Set initial absolute position.
                     self.mouse_x = x;
@@ -179,8 +177,8 @@ impl CameraState {
                 self.mouse_x = x;
                 self.mouse_y = y;
             }
-            &KeyboardInput { input, .. } => {
-                let pressed = input.state == glutin::ElementState::Pressed;
+            &glium::glutin::WindowEvent::KeyboardInput { input, .. } => {
+                let pressed = input.state == glium::glutin::ElementState::Pressed;
                 let key = match input.virtual_keycode {
                     Some(key) => key,
                     None => return,
index a515bde2a2ffe4fd50e0f8046db33f00f06d6c33..175c7fd83293360799d27b27666143a302b8fbae 100644 (file)
@@ -1,5 +1,3 @@
-extern crate glutin;
-
 use std::f32;
 use std::ops::Add;
 use std::ops::AddAssign;